diff options
Diffstat (limited to 'japh')
-rw-r--r-- | japh | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -23,39 +23,41 @@ function japh() { "n") if [ -z $2 ]; then echo "Command must not be empty!" - japh_usage - else - cmd_name=$2 + return + fi - cmd_tmp_file=/tmp/japh_$cmd_name + cmd_name=$2 - $EDITOR $cmd_tmp_file + cmd_tmp_file=/tmp/japh_$cmd_name - if [ ! -s $cmd_tmp_file ]; then - echo "You must have a command!" - else - printf "function cmd_$cmd_name() {\n" >> $JAPH_DIR/cmds - cat $cmd_tmp_file >> $JAPH_DIR/cmds - printf "\n}\n" >> $JAPH_DIR/cmds - fi + $EDITOR $cmd_tmp_file + + if [ ! -s $cmd_tmp_file ]; then + echo "You must have a command!" + else + printf "function cmd_$cmd_name() {\n" >> $JAPH_DIR/cmds + cat $cmd_tmp_file >> $JAPH_DIR/cmds + printf "\n}\n" >> $JAPH_DIR/cmds + rm $cmd_tmp_file fi ;; "r") if [ -z $2 ]; then echo "Command must not be empty!" japh_usage - else - source $JAPH_DIR/cmds - type cmd_$2 &> /dev/null - status=$? + return + fi - if [ $status -eq 0 ]; - then - cmd_$2 - else - echo "Command was not found!" - japh_usage - fi + source $JAPH_DIR/cmds + type cmd_$2 &> /dev/null + status=$? + + if [ $status -eq 0 ]; + then + cmd_$2 + else + echo "Command was not found!" + japh_usage fi ;; "help" | "-h") |