-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminishell_command.txt
216 lines (158 loc) · 5.22 KB
/
minishell_command.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/bin/ls -l -a -R
/bin/ls -laF
pwd
uname -r
ls -l
ls -la
env
/usr/bin/env
emacs
echo"something here"
exit
$ wc << EOF
> one two three
> four five
> EOF
2 5 24
In this example we tell wc program to wait for EOF string, then type in five words, and then type in EOF to signal that we're done giving input. In effect, it's similar to running wc by itself, typing in words, then pressing CtrlD
The dollar sign before the thing in parenthesis usually refers to a variable. This means that this command is either passing an argument to that variable from a bash script or is getting the value of that variable for something.
If readline encounters an EOF (Ctrl + D) while reading the line, and the line is empty at that point, then (char *)NULL is returned. Otherwise, the line is ended just as if a newline \n had been typed.
echo "hello $USER " > file | grep h | cat << eof | cat >> file | echo 'done'
c4c3c3% FOO=4
c4c3c3% echo $FOO
c4c3c3% export EDITOR=nano
c4c3c3% printenv EDITOR
nano
c4c3c3% export EDITOR=nano
c4c3c3% $EDITOR
c4c3c3% unset EDITOR
c4c3c3% $EDITOR
c4c3c3% export BB=pwd
c4c3c3% $BB
/nfs/homes/yli/Desktop/Subject
◦ echo with option -n done good
◦ cd with only a relative or absolute path done notgood
◦ pwd with no options done good
◦ export with no options done good
◦ unset with no options done notgood
◦ env with no options or arguments done good
◦ exit with no options done notsure
ls -l | wc -l > aa > bb > cc > dd
cat > out | cat | cat | ls
yli@c4c1c2:~$ cat << EOF
> $USER
> 12
> 12
> 12
> EOF
yli
12
12
12
yli@c4c1c2:~$ cat | cat | cat | ls
Desktop echo Music Public testshow
Documents francinette Pictures sgoinfre Videos
Downloads goinfre Postman Templates 'VirtualBox VMs'
yli@c4c1c2:~$
yli@c4c1c2:~$ cat << EOF
> $?
> 12
> EOF
0
12
yli@c4c1c2:~$
c4c3c3% echo "test"
test
c4c3c3% $?
zsh: command not found: 0
c4c3c3% dkflskd
zsh: command not found: dkflskd
c4c3c3% $?
zsh: command not found: 127
echo "abc"
echo "abc $USER"
echo "$USER"
echo "$USER$USER"
echo "abc $USER$USER"
echo "abc $USER23$USER"
echo "abc $USER$USER "
echo "abc $USER23$USER sadsa"
echo sfsd $?
[minishell:]echo "sfs$USER65"
sfs
[minishell:]echo dsfd$?dfsd
munmap_chunk(): invalid pointer
zsh: IOT instruction (core dumped) ./a.out
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo abc$USER
abcyli
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo abc$USERsfd
abc
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo abc$USER45
abc
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo abc$USER45$USER
abcyli
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo "abc$USER45$USER"
abcyli
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo "abc$USER45$PATH"
abc/nfs/homes/yli/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $USER45$PATH
/nfs/homes/yli/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $USER$PATH
yli/nfs/homes/yli/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $?$PATH
0/nfs/homes/yli/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $?\n$PATH
0n/nfs/homes/yli/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $?\n
0n
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo \n45
n45
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $?45
045
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo $?fsdf
0fsdf
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo 545$?fsdf
5450fsdf
yli@c4a4c9:~/Desktop/Project/minishell/minishell$ echo 422$?4
42204
[minishell:]echo "123""456"
123456
[minishell:]echo '123'"456"
123456
[minishell:]echo '123''456'
123456
[minishell:]echo ""123""456
123456
should be: 123456
[minishell:]echo -nnan"$USER c $?$HOME" ab //ok
-nnanyli c 0/home/yli ab
[minishell:]echo 45"aa$USER'dd'"bb //1
45aayli'dd'bb
yli@c4c6c3:~/Desktop/Project/minishell/final$ echo 'ab "$USER"dd'12 12
ab "$USER"dd12 12
yli@c4c6c3:~/Desktop/Project/minishell/final$ echo "abc '$USER'cc" 123
abc 'yli'cc 123
[minishell:]echo $USER$HOME
yli/home/yli
[minishell:]echo $USER$HOME$?
yli/home/yli0
[minishell:]echo $USER$HOME$?""
yli/home/yli0
[minishell:]echo "$USER$HOME$?"
yli/home/yli0
[minishell:]echo "" $HOME"34"
/home/yli34
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo "" "$HOME'34'"
/home/yli'34'
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo "" $HOME"34"
/home/yli34
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo "" $HOME'34'
/home/yli34
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo "" "$HOME'34'"
/home/yli'34'
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo "" '$HOME'34''
$HOME34
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo $""
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo $''
yli@c4b10c3:~/Desktop/Project/minishell/final$ echo $'34'
34