Mr.Macdonald
August 11th, 2009, 03:23 AM
I wrote this script
#!/bin/bash
COMMANDS=`echo $@ | awk -F'-' '{ for (i=1;i<=NF;i++) { \
print "\"" $i "\"" \
} }' | grep -v "\"\""`
echo $COMMANDS
for CM in $COMMANDS
do
echo NQ $CM
done
to do this
(assuming called test.sh)
# ./test.sh -new another -del older
NQ new another
NQ del older
yet I get this
# ./test.sh -new another -del older
NQ "new
NQ another
NQ "
NQ "del
NQ older"
I understand what bash is trying to do, but thats not what I told it to do, I think
basically if you are interested, this is supposed to break command line arguments into sections defined by options. They are to be broken into easily executable function calls
ie.
the new function and the del function
#!/bin/bash
COMMANDS=`echo $@ | awk -F'-' '{ for (i=1;i<=NF;i++) { \
print "\"" $i "\"" \
} }' | grep -v "\"\""`
echo $COMMANDS
for CM in $COMMANDS
do
echo NQ $CM
done
to do this
(assuming called test.sh)
# ./test.sh -new another -del older
NQ new another
NQ del older
yet I get this
# ./test.sh -new another -del older
NQ "new
NQ another
NQ "
NQ "del
NQ older"
I understand what bash is trying to do, but thats not what I told it to do, I think
basically if you are interested, this is supposed to break command line arguments into sections defined by options. They are to be broken into easily executable function calls
ie.
the new function and the del function