I have this bash script getting a Boolean parameter, based on the answer here
I created this simple condition, for some reason I am getting false results
#!/bin/bash
copyFile() {
echo "copyFile #Parameter:$1"
if [ "$1" ]; then
echo "Parameter is true"
else
echo "Parameter is false"
fi
}
copyFile true
copyFile false
execution result:
[admin@local_ip_tmp]$ ./test.sh
copyFile #Parameter:true
Parameter is true
copyFile #Parameter:false
Parameter is true
The last result should have "Parameter is false" I am not sure what is going on.
What am doing wrong?