Why does a Bash script with select exit without input when reading from stdin?
0
votes
1
answer
150
views
I'm working on a Bash script that optionally accepts input from stdin and then presents the user with a selection menu using select. The issue arises when the script is provided data via stdināthe select menu displays but exits immediately without accepting any input. It works fine when no stdin data is provided.
Here is a minimal example:
#!/usr/bin/env bash
if [[ -p /dev/stdin && ${#bar[@]} -eq 0 ]]; then
while IFS= read -r foo; do
bar+=("$foo")
done
Asked by jesse_b
(41447 rep)
Oct 5, 2023, 06:54 PM
Last activity: Dec 19, 2024, 07:26 PM
Last activity: Dec 19, 2024, 07:26 PM