bash 5.2.x + ternary operator: How can I use this combo when checking if my string variable is empty or not?
0
votes
1
answer
1303
views
I have tried
#!/bin/bash
distro=""
myvar1=[[ -n "$distro" ]] && echo $distro || echo "debian"
myvar2=$((-n $distro ? $distro : "debian"))
these are the results of the script
./build.sh: line 5: -n: command not found
debian
./build.sh: line 6: -n ? : debian: expression expected (error token is ": debian")
Asked by mrjayviper
(2253 rep)
Aug 6, 2024, 05:50 AM
Last activity: Aug 6, 2024, 07:40 AM
Last activity: Aug 6, 2024, 07:40 AM