Tiny Core Base > TCB Bugs
/usr/bin/select shell script menu TC 4.6.1 and TC 5.2
KHarvey:
I'm attempting to write a shell script that prompts the user to select from a menu of choices. But I am unable to get the select statement to work. I keep receiving an error
--- Code: ---/usr/bin/select: line xx: can't open in: no such file
--- End code ---
xx in TC 4.6.1 is 54
xx in TC 5.2 is 62
I attempted to just use a basic script to make sure that it wasn't my convoluted code:
--- Code: ---#!/bin/bash
OPTIONS="Hello Quit"
select opt in $OPTIONS; do
if [ "$opt" = "Quit" ]; then
echo done
exit
elif [ "$opt" = "Hello" ]; then
echo Hello World
else
clear
echo bad option
fi
done
--- End code ---
But even that code fails with the same error.
I can probably write the same thing using if statements and accomplish the same thing. But I figured I would ask anyways.
Please note I have not tried any of this code on another distro, I have only tried it on TC.
gerald_clark:
bash is /usr/local/bin/bash, not /bin/bash.
KHarvey:
Gah!
I was actually using /bin/sh for my script. The example that I posted above was copied and pasted from the website that I was using to test.
But if I use /usr/local/bin/bash then the script runs properly. I have a lot of scripts that I need to go change from /bin/sh to /usr/local/bin/bash.
Thanks for pointing out my error.
Greg Erskine:
--- Quote from: KHarvey on May 30, 2014, 02:27:31 PM ---Gah!
I was actually using /bin/sh for my script. The example that I posted above was copied and pasted from the website that I was using to test.
But if I use /usr/local/bin/bash then the script runs properly. I have a lot of scripts that I need to go change from /bin/sh to /usr/local/bin/bash.
Thanks for pointing out my error.
--- End quote ---
Hi KHarvey,
You may not need to change all your scripts.
Although I have limited knowledge about the differences of shells, I believe it is because you wanted to use an array that you need to use the bash shell.
AFAIK sh does not support arrays directly.
regards
tinypoodle:
--- Quote from: KHarvey on May 30, 2014, 02:27:31 PM ---
I have a lot of scripts that I need to go change from /bin/sh to /usr/local/bin/bash.
--- End quote ---
That sounds like really bad practice in two aspects:
1. Never ever use a bash header for portable shell scripts without explicit bashisms.
2. Never ever use #!/usr/local/bin/bash as header for bash scripts, but always #!/usr/bin/env bash.
Navigation
[0] Message Index
[#] Next page
Go to full version