Re: [CentOS] bash: return status of an assignment

2021-02-27 Thread Gordon Messmer
On 2/27/21 4:39 PM, Skylar Thompson wrote: You can fix it if you group the assignments together: [ -z "$INSMOD" ] && (INSMOD=$(which modprobe) || INSMOD="$(which insmod)") They do need to be grouped, but if you group them with parentheses, they execute in a subshell, and the assignment is los

Re: [CentOS] bash: return status of an assignment

2021-02-27 Thread Skylar Thompson
I think this is a problem with the precedence of && vs ||. If INSMOD is not set, it will work as you intend, but once it's set, only the || branch will execute. You can fix it if you group the assignments together: [ -z "$INSMOD" ] && (INSMOD=$(which modprobe) || INSMOD="$(which insmod)") On Sat

Re: [CentOS] bash: return status of an assignment

2021-02-27 Thread Gordon Messmer
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) || I

[CentOS] bash: return status of an assignment

2021-02-27 Thread Kenneth Porter
In the sqm-scripts package for managing network traffic shaping is this line for finding a program suitable for loading the kernel shaping modules: [ -z "$INSMOD" ] && INSMOD=$(which modprobe) || INSMOD=$(which insmod) It seems to set INSMOD to /usr/sbin/insmod, even though /usr/sbin/modprobe