Argc and Argv in Bash

Viewed 26394

I written the following script which gets name of a file and then assemble and link the file. But it doesn't work. What is the problem with it?

EXPECTED_ARGS=2


if [ $# -ne $EXPECTED_ARGS ]
then
        echo "[+] Assembling with Nasm."
        nasm -f elf32 $1 -o $1.o

        echo "[+] Linking ..."
        ld $1.o -o $1

        echo "[+] Done!" 

else
        printf  "\nInvalid number of arguments, please check the inputs and try again\n"

fi;

When I run it without passing any args, it doesn't shows following error:

printf  "\nInvalid number of arguments, please check the inputs and try again\n"
1 Answers
Related