-
Story
-
Resolution: Done
-
Major
-
RH254 - RHEL 7 1 20140711
-
None
-
12
URL:
Reporter RHNID:
Section: -
Language:
Workaround:
Description: As it stands, now, the code on pp 353 is as follows:
[student@serverX bin]$ cat showargs
#!/bin/bashfor ARG in "$*"; do
echo $ARG
done[student@serverX bin]$ ./showargs 1 2 3
1 2 3[student@serverX bin]$ cat showargs
#!/bin/bashfor ARG in "$@"; do
echo $ARG
done[student@serverX bin]$ ./showargs 1 2 3
1
2
3
My students didn't really get what was going on here. And I don't blame them – this doesn't really prove anything.
The improvement I would suggest: pass some quoted arguments which contain spaces to showargs, e.g.:
[student@serverX bin]$ cat showargs
#!/bin/bashfor ARG in "$*"; do
echo $ARG
done[student@serverX bin]$ ./showargs "argument 1" 2 "arg 3"
argument 1 2 arg 3[student@serverX bin]$ cat showargs
#!/bin/bashfor ARG in "$@"; do
echo $ARG
done[student@serverX bin]$ ./showargs "argument 1" 2 "arg 3"
argument 1
2
arg 3
I also think the two sentences on pp 352 starting with "When $* is used, all of the arguments are seen as as single word" are technically wrong, but honestly less important than a good demonstration.