2015-03-08 Bash Pitfalls

Last edit

Changed:

< Bash is hard, but that's not an excuse.
< Every time I see something like this:
< <stupi>
< <dity!>
< #!/bin/sh
< read FOLDER
< [[ ! -d $FOLDER ]] && mkdir $FOLDER || printf "Directory $FOLDER already exists"
< echo $myVar > $FOLDER/log
< echo Please copy your files to $FOLDER
< read > /dev/null # wait for Enter
< sleep 1 &
< wget -Out http://link.org
< if [[ $num1 > $num2 ]]
< then
< echo 'Error!'
< clear
< fi
< PATH=data/stuff;
< cd $PATH;
< sudo echo $'Script started' >> /etc/mylog
< echo "Math test: 0 + 2 = ${0+2}"
< rm -rf $FOLDER
< <//>
< <//>
< I feel horrible. It is like my insides are falling out! ARGH!
< ==But this is not getting better at all!
< Is it so hard to go through the list on [[http://mywiki.wooledge.org/BashPitfalls BashPitfalls page]]? I don't think so. However, most people would much rather follow retarded Google style gu-fucking-ides than learn the language they are using.
< <white>
< [[image:File:bash_promise.svg|*BASH-BASH-BASH*]]
< ([[http://creativecommons.org/licenses/by-sa/4.0/ CC BY-SA 4.0]] by [[About|me]])
< I post comments like this from time to time:
< https://alexschroeder.ch/wiki/Comments_on_2014-06-23_Oddmuse_Migration
< But look, this time was special because someone decided to post a link to [[https://google-styleguide.googlecode.com/svn/trunk/shell.xml google style guide]] and claimed that it is a "nice resource". I've extracted my comment into [[2015-03-14 The Downsides of Free Food]], please check it out.
< ==Is there any hope?
< Yes, get yourself a steel pipe.
< Joking aside, lets start something interesting now! I will pick a pseudo-random open-source project every week (or at least every month) and refactor it. I will document everything on this blog. Later, if there are enough refactored projects and if this stuff becomes interesting to people, I will extract it to a separate wiki. Of course, every time I will do a pull request with all of the changes.
< Although I try to make the code perfect, sometimes it is not possible to do it fully. Things for you to note:
< * Sometimes it is too hard to find out the purpose of some poorly-written dumbfuscated code, I might not touch such lines. There is a high chance to break stuff in such situations, and sometimes the behavior of edge-cases will change. I think that such lines could be dealt with later, when my more obvious changes are commited.
< * I don't want to spend too much time on one project, and I will not pick the same project twice. Therefore some possible changes might be left behind. Feel free to do some post-fixes yourself!
< * I'm not a Bash god, you will find much more experienced people on #bash, for example. This means that I might not be capable of fixing some tricky bugs.
< The goal of this project is to spread the knowledge about bash pitfalls and improve the quality of open-source projects.
< Please be conscious.
< [[tag:bash]]

to

> DeletedPage


DeletedPage