xclip 명령줄의 축약된 긴 옵션

xclip 명령줄의 축약된 긴 옵션

맨페이지에서xclip

-selection

specify which X selection to use, options are 
"primary" to use XA_PRIMARY (default), 
"secondary" for XA_SECONDARY or 
"clipboard" for XA_CLIPBOARD

Note that only the first character of the selection specified with the -selection option is important. 
This means that "p", "sec" and  "clip"  would
have the same effect as using "primary", "secondary" or "clipboard" respectively.

클립보드를 사용하여 선택하는 방법은 다음과 같습니다.

    xclip -sel clip < ~/.ssh/id_rsa.pub

맨페이지에는 clipboard로 단축할 수 있다고 나와 있지만 로 단축할 수 있다고 clip는 나와 있지 않습니다 .-selection-sel

그렇다면 왜 작동합니까? 옵션을 지정하는 이 기능은 xclip다른 많은 응용 프로그램에 속합니까 , 아니면 추가됩니까 xclip?

답변1

xclip옵션 구문 분석을 위해 X Toolkit 라이브러리를 사용하십시오. 모든 옵션은 축약될 수 있습니다. 모호성이 있는 경우 라이브러리는 오류를 표시합니다.

물론 옵션은 -select로 축약될 수 있는 것 입니다 -sel(심지어 가능함 ).-s

xterm동일한 라이브러리, 동일한 동작을 사용합니다. 특수한 경우(라이브러리 외부)를 사용하여 -v명령을 고유한 약어로 만듭니다 -version.

X 툴킷은 -옵션에 단일 대시를 사용하며 내가 지적한 것처럼 "짧음"과 "긴"을 구분하지 않습니다 getopt.-단일 문자 옵션에는 단일 대시가 있고 --단어에는 이중 대시가 있습니까?, 이는 GNU getopt와 거의 같은 시기에 소개되었습니다.했다연장하다 getopt. POSIX 이전이었지만AT&T getopt수년 간의 사용 끝에 단일 문자 옵션에서의 역할이 확립되었습니다. GNU는 getopt이중 대시를 사용 --하여옵션.

xclipGNU getopt의 소스 코드를 읽을 수 있는 긴 여담을 참고하세요(관련 없음).Git 저장소,예를 들어,

 369    Long-named options begin with `--' instead of `-'.
 370    Their names may be abbreviated as long as the abbreviation is unique
 371    or is an exact match for some defined option.  If they have an
 372    argument, it follows the option name in the same ARGV-element, separated
 373    from the option name by a `=', or else the in next ARGV-element.
 374    When `getopt' finds a long-named option, it returns 0 if that option's
 375    `flag' field is nonzero, the value of the option's `val' field
 376    if the `flag' field is zero.

답변2

가장 최근 맨페이지에는 (적어도) 다음과 같이 나와 있습니다.

명확하게 유지되는 한 옵션을 축약할 수 있습니다. 예를 들어 다음을 사용할 수 있습니다.-디또는-보여주다바꾸다-전시하다. 하지만,-V불명확하므로 사용할 수 없습니다(약어일 수도 있음).-상세한또는-버전)이므로 파일 이름으로 해석됩니다.

-se이는 에는 충분 -selection하지만 니모닉 관점에서는 좋지 않다는 것을 의미합니다 -sel.

관련 정보