Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Can mktemp fail?

Yes it can. You should use its exit status (or set -e). See http://man.openbsd.org/mktemp

Note that there is a nasty trap if you're using local to declare and set a variable:

    a () { local M=`ls /asdf` && echo y; }
    b () {       N=`ls /asdf` && echo y; }
    a ; b ;
One will print y, the other will not.


Shellcheck helpfully warns about declaring and assigning in the same statement exactly because it masks exit status.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: