LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell script issue (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-issue-4175454945/)

jcky 03-21-2013 12:46 AM

shell script issue
 
#!/bin/bash
function DEBUG()
{
[ "$_DEBUG" == "on" ] && $@ || :
}

for i in {1..10}
do
DEBUG echo $i
done


What does $_DEBUG mean?

And what's its grammar ?

Thanks.

chrism01 03-21-2013 01:35 AM

Code:

_DEBUG
is a bash var, probably set in the calling env.

shivaa 03-21-2013 03:41 AM

_DEBUG is some variable in your script. But it doesn't seem a complete script, but just a snippet of it. So let's know what exactly you want to do?

In the meantime, following should work:
Code:

#!/bin/bash
_DEBUG=<some_value>
DEBUG()
{
[ "$_DEBUG" == "on" ] && $@ || :
}

for i in {1..10}
do
DEBUG echo $i
done


kooru 03-21-2013 03:51 AM

You should post the complete code to undestand if the _DEBUG is into the script ;)
Have you used the code form here?: http://manoftoday.wikidot.com/bash :D


All times are GMT -5. The time now is 11:20 PM.