samona Posted December 28, 2008 Share Posted December 28, 2008 Hi, I was wondering if someone could explain what the following code means. if test "x$output" = "x" Also, why would you put "x$output" why not just "$output" ? Quote Link to comment https://forums.phpfreaks.com/topic/138605-shell-programmin/ Share on other sites More sharing options...
corbin Posted December 28, 2008 Share Posted December 28, 2008 The only thing that I can think of is that it's checking if $output is empty.... Maybe someone that actually knows what's going on can help more though ;p. Quote Link to comment https://forums.phpfreaks.com/topic/138605-shell-programmin/#findComment-724762 Share on other sites More sharing options...
samona Posted December 28, 2008 Author Share Posted December 28, 2008 Yeah, i think you're right. So if $output is empty then x$output would equal x. But why not just say if $output="" or maybe that's not possible in shell programming? Quote Link to comment https://forums.phpfreaks.com/topic/138605-shell-programmin/#findComment-724777 Share on other sites More sharing options...
trq Posted December 28, 2008 Share Posted December 28, 2008 The only thing that I can think of is that it's checking if $output is empty.... It is indeed, in a very roundabout way. There a better methods built into bash. if [ -z $output ] ; then echo '$output is empty' fi Quote Link to comment https://forums.phpfreaks.com/topic/138605-shell-programmin/#findComment-724798 Share on other sites More sharing options...
corbin Posted December 28, 2008 Share Posted December 28, 2008 Weird.... Quote Link to comment https://forums.phpfreaks.com/topic/138605-shell-programmin/#findComment-724959 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.