Reputation: 449
I try to make script in c-shell which is checking if it is called with -g or -h arguments. If it is called with some other argument it should simply echo "Wrong argument". The problem is that when I run script with -s etc my r value isn't True and I have "if: no file name" error in console. Here's my loop:
foreach a ($argv)
if (( $a == '-h' ) || ( $a == '--help' )) then
set h=True
else if (( $a == '-q' ) || ( $a == '--quiet' )) then
set q=True
else
set r=True
endif
end
Thanks in advance.
Upvotes: 1
Views: 3102
Reputation: 449
I figured out I need to put "$a" and i.e. "-h" into "". So the code looks like this now:
foreach a ($argv)
if (( "$a" == "-h" ) || ( "$a" == "--help" )) then
set h=True
else if (( "$a" == "-q" ) || ( "$a" == "--quiet" )) then
set q=True
else
set r=True
endif
end
I hope it will help someone.
Upvotes: 1