1

I have this shell script:

for i in "$@"
do
case $i in
    -l=*|--ddloc=*)
    DDLOC="${i#*=}"
    shift # past argument=value
    ;;
    *)
          # unknown option
    ;;
esac
done

Its working fine as -x=y but i want to be like -x y. What changes will be required here?

tripleee
  • 158,107
  • 27
  • 234
  • 292
Manish Kumar
  • 9,824
  • 21
  • 74
  • 137

1 Answers1

1
for i in "$@"
do
case $i in
    -l=*|--ddloc=*)
    DDLOC="${i#*=}"
    shift # past argument=value
    ;;
    -l|--ddloc)
    shift # past argument
    DDLOC="$1"
    shift # past value
    ;;
    *)
          # unknown option
    ;;
esac
done
jhnc
  • 6,479
  • 6
  • 20