bash script with cli options returns command not found -


this question has answer here:

i have bash script set keyboard type of external , internal laptop keyboards (so both usable , output correct characters).

the main part of script works fine, have problem switch / case capturing command line options.

this full script

#!/bin/bash   ###functions first  usage() { echo "script set internal , external keyboards french , english repectively"  }   setkeyboardmap() {     echo "setting dual keyboard."     echo "setting keyboard types..."     setxkbmap -device 13 fr     setxkbmap -device 10 gb      echo "done" }   ##the main show  #capture command line parameters   if ["$1" = ""];     #no command line parameters     setkeyboardmap     exit 0 else  while [ "$1" != " "];     case $1 in         -h | --help)    usage                 exit 1                 ;;     -*|--*)     echo "unknown option $1"     echo "please use -h or --help usage details"     exit 1     ;;      #add switches in here     #you may decide modify set keyboard     #according prefered type.       esac  done  fi 

when call home directory following

:~$ bash -x 2keyb.sh -h + '[-h' = ']' 2keyb.sh: line 31: [-h: command not found + '[' -h '!=' ' ]' 2keyb.sh: line 37: [: missing `]' 

i'm not sure i'm missing i'm sure in while statement.

i know having construct command line arguments bit excessive, plan make usable on laptop set keybaord language between 2.

but first need working it.

if don't pass arguments script functions perfectly...

thanks in advance, appreciated.

david

while [ "$1" != " "]; ^^ space missing here mentioned codegnome there shellcheck, static analyzer shell scripts. use shellcheck binary in combination vim , syntastic plugin -> useful find kind of errors.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -