Skip to main content
9 events
when toggle format what by license comment
Jul 30, 2014 at 2:31 comment added mikeserv Yes - echo ${name:?variable is empty} will either evaluate to $name's non-null value or it will kill the shell. So for the same reason you don't do prompt > $randomvar neither should you ${var?} - if there's a command in there, it's probably going to run - and you don't know what it is. An interactive shell doesn't have to exit - which is why yours doesn't. Still, if you want to see some tests, there are a lot of them here.. This one isn't quite as long...
Jul 29, 2014 at 16:24 comment added pratik how it will kill shell. and u can also test this , first define name=aaaa then run this command echo ${name:?variable is empty} it will print value of variable name and now run this command echo ${name1:?variable is empty} it will print -sh: name1: variable is empty
Jul 29, 2014 at 12:59 comment added mikeserv be careful - that kills the current shell. Better to put it in a (: ${subshell?}). Also - that will write to stderr - you probably want redirect. And most important that evaluates to the variable's actual value if it is not unset or null. If there's a command in there, you just ran it. It's best to run that test on :.
Jul 29, 2014 at 11:19 comment added Bernhard I think your answer is downvoted because the "or contain spaces" is not true.
S Jul 29, 2014 at 11:17 history suggested Nidal CC BY-SA 3.0
improved formmating
Jul 29, 2014 at 11:14 review Low quality posts
Jul 29, 2014 at 11:20
Jul 29, 2014 at 11:02 review Suggested edits
S Jul 29, 2014 at 11:17
Jul 29, 2014 at 10:58 review First posts
Jul 29, 2014 at 11:02
Jul 29, 2014 at 10:58 history answered pratik CC BY-SA 3.0