Handling arguments in bash alias
Short snippet showing how to handle n arguments in a bash alias.
The example accepts n filenames, checks if the files exist in haml within the directory and attempts to compile the haml code to html.
haml_args(){
for file in "$@"
do
if [ ! -f "$file.haml" ];
then
echo "Error: $file.haml does not exist"
else
echo "Compiling $file.haml .........."
haml $file.haml $file.html
echo "Finished"
fi
done
}
alias hamlc=haml_args
If you have a better way to do this, please enlighten me!
Written by Ezekiel Kigbo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Haml
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#