Created
January 11, 2016 19:21
-
-
Save lidio601/c690047e58b45e53c95b to your computer and use it in GitHub Desktop.
In Bash scripting when you want to print useful information when debugging a script from terminal but not when executed in background (like from crontab)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -t 1 ] | |
then | |
: # running from terminal | |
debug="1" | |
else | |
: # not running from terminal, cron maybe | |
debug="0" | |
fi | |
if [ "$debug" -eq "1" ]; then | |
echo "Printing my debug information" | |
fi | |
# blablabla useful code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment