I want to check if the user has given the script any arguments and if this is the case, the script should close.
if [ $@ = "" ]; then exit fi is not working.
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalI want to check if the user has given the script any arguments and if this is the case, the script should close.
if [ $@ = "" ]; then exit fi is not working.
$#$@because of how bash handles empty strings. Unquoted, the first line becomesif [ = "" ]; thenwhen no arguments are passed in, which results in a syntax error. Quoted, you haveif [ "" = "" ]; then, which is treated as expected.