Thread View: gnu.bash.bug
1 messages
1 total messages
Started by Michael R. M. Cheselka
Sun, 09 Aug 1992 05:12
"$@" doesn't always work the same.
Author: Michael R. M. Cheselka
Date: Sun, 09 Aug 1992 05:12
Date: Sun, 09 Aug 1992 05:12
78 lines
2099 bytes
2099 bytes
In UNIX Shell Programming( revised edition, 0-672-48448-X), by Kochan and Wood, on pages
193-194, the following programming example is shown:
Script started on Sat Aug 8 23:47:22 1992
bash$ source ~/.bashrc
cactus: ~ $ cat >args
for arg in "$@"
do
echo $arg
done
cactus: ~ $ chmod ug+x args
cactus: ~ $ set -x
cactus: ~ $ args a b c
+ args a b c
++ echo a
a
++ echo b
b
++ echo c
c
cactus: ~ $ args 'a b' c
+ args a b c
++ echo a b
a b
++ echo c
c
cactus: ~ $ cat > file
+ cat
a b c
cactus: ~ $ args `cat file`
++ cat file
+ args a b c
++ echo a
a
++ echo b
b
++ echo c
c
cactus: ~ $ cat > file
+ cat
'a b' c
cactus: ~ $ args `cat file`
++ cat file
+ args 'a b' c
++ echo 'a
'a
++ echo b'
b'
++ echo c
c
cactus: ~ $ exit
+ exit
exit
script done on Sat Aug 8 23:50:26 1992
Why is there a difference?! How can there be a difference! I notice it is
the same for sh as well. I need to see if people have gotten accounts
created by using nawk to pull out names from a file in the form:
Firstname M. I. Lastname
Nextperson J. Random
...and on...
Then form a list in a file:
'Firstname M. I. Lastname' 'Nextperson J. Random' ...and on...
Use a for loop:
for arg in "@" ; do
grep $arg /etc/passwd | nawk -F: '{print $5 "\'s account has been created"}'
done
What is the correct way to do this?
--
cheselka@cactus.org N5UVV Michael R. M. Cheselka
os9@gnu.ai.mit.edu (512)452-9412v ( 24hours answer. mach.)
membership@cactus.org Hangs out on 145.21mhz 400 W. 34th st. #103
{...}!cs.utexas!cactus.org!cheselka Austin, Texas, 78705-1331
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads