2 added 28 characters in body
source | link

From Bash Manual, for filename expansion:

If the nullglob option is set, and no matches are found, the word is removed.

My following script will return exit status 1.

  • Can filename expansion failing to match any jpg file in my current directory cause my script to exit with 1?

  • How can I rule out other possibility for exit status 1?

Thanks.

shopt -s nullglob

for i in *.{png,jpg};
do
    filename=${i##*/}
    basename=${filename%.*}
    [ ! -e ${basename}.pdf ] && convert  "$i"  ${basename}.pdf ;
done

From Bash Manual, for filename expansion:

If the nullglob option is set, and no matches are found, the word is removed.

My following script will return exit status 1.

  • Can filename expansion failing to match any jpg file in my current directory cause my script to exit with 1?

  • How can I rule out other possibility for exit status 1?

Thanks.

shopt -s nullglob

for i in *.{png,jpg};
do
    filename=${i##*/}
    basename=${filename%.*}
    convert  "$i"  ${basename}.pdf ;
done

From Bash Manual, for filename expansion:

If the nullglob option is set, and no matches are found, the word is removed.

My following script will return exit status 1.

  • Can filename expansion failing to match any jpg file in my current directory cause my script to exit with 1?

  • How can I rule out other possibility for exit status 1?

Thanks.

shopt -s nullglob

for i in *.{png,jpg};
do
    filename=${i##*/}
    basename=${filename%.*}
    [ ! -e ${basename}.pdf ] && convert  "$i"  ${basename}.pdf ;
done
1
source | link

Does filename expansion failing to match any file cause a script to exit with 1?

From Bash Manual, for filename expansion:

If the nullglob option is set, and no matches are found, the word is removed.

My following script will return exit status 1.

  • Can filename expansion failing to match any jpg file in my current directory cause my script to exit with 1?

  • How can I rule out other possibility for exit status 1?

Thanks.

shopt -s nullglob

for i in *.{png,jpg};
do
    filename=${i##*/}
    basename=${filename%.*}
    convert  "$i"  ${basename}.pdf ;
done