This is an open series in which Hacker Public Radio Listeners can share their Bash scripting knowledge and experience with the community. General programming topics and Bash commands are explored along with some tutorials for the complete novice.
Carl talks about a method to move function definitions to the bottom of a script using sed:
Guest Host #1 (scroll to the bottom to ruin the surprise) talks about the shift command using this example:
startdate="$1" # Pick up date
# Loop through args and create events
while [ $1 ] ; do # as many times as you add a timestamp
[ $1 != "off" ] && khal new $(date -j -v+"$days"d -f %Y-%m-%d +%Y-%m-%d $startdate) $1 8H Work
Guest Host #2 provides tips and examples on how to use variables safely and politely provide default values. One example of assigning a default value is:
Carl then closes out with the : (colon) shell builtin and provides a variation on the above default value:
Thanks for this, Carl! Couldn't imagine a better host! You are exactly right about the reason to talk about shift: you see it in scripts out there and it can be quite hard to glean what it does if you don't already know it. I also thank you for the observation on the word shift, which I actually hadn't noticed! The name of that script was myshifts.sh, so it's impossible to tell if it refers to the repeated running of the shift command or to the resulting calendar events. I like it!
Comment #2 posted on 2022-06-27 11:23:40 by Carl
Thanks for the comment and the contribution to the show dnt, you and klaatu really helped me get something out the door. My timing was off as usual as I should have had my recording process figured out beforehand but I'll improve it before the next show. The work/shift example was perfect!
Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.
Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).