代码之家  ›  专栏  ›  技术社区  ›  Manish Kumar

按空间指定的读取Shell脚本选项

  •  0
  • Manish Kumar  · 技术社区  · 7 年前

    我有一个shell脚本:

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

    -x=y 但我想成为 -x y

    1 回复  |  直到 6 年前
        1
  •  1
  •   jhnc    7 年前
    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