Re: bash: return status of an assignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 2/27/21 1:32 PM, Kenneth Porter wrote:
[ -z "$INSMOD" ] && INSMOD=$(which modprobe) || INSMOD=$(which insmod)

It seems to set INSMOD to /usr/sbin/insmod, even though /usr/sbin/modprobe is available. (Both are symlinks to ../bin/kmod.)


    [ -z "$INSMOD" ] && INSMOD=$(which modprobe) || INSMOD=$(which insmod)

This should be re-written as:

    [ -z "$INSMOD" ] && { INSMOD=$(which modprobe) || INSMOD=$(which insmod) ; }

As it is currently written, if INSMOD is set previously, it will be replaced with the output of "which insmod".  That is, the final statement will be evaluated if either INSMOD was set previously, or if "which modprobe" exits with a non-zero status.

It's unlikely that this is a PATH issue since both modprobe and insmod are in the same directory.  The most likely explanation is that $INSMOD had a value before that line was evaluated.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux