I have written a 'to_upper' function using bash scripting:
to_upper() {
local string=$1
echo $string | tr "[:lower:]" "[:upper:]"
return 0
}
However, the output of:
VAL=bla
echo $(to_upper bla)
echo $(to_upper $VAL)
is
BLA
1
Does anyone know what is going on here?
NOTE: It seems my example does not reproduce my error. However, what I do have is this situation:
DEVICE_STATUS=$(get_device_status)
echo $DEVICE_STATUS $(to_upper $DEVICE_STATUS)
The output is then:
active 1
My example seems to not reproduce the problem, but it's there on my script.
NOTE 2: I fixed the problem; it was some grep output on the get_device_status function which ended up on $DEVICE_STATUS.