chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #1012: getopt-long discards doublequotes and option v


From: Chicken Trac
Subject: [Chicken-janitors] #1012: getopt-long discards doublequotes and option values after whitespace characters
Date: Wed, 15 May 2013 09:38:02 -0000

#1012: getopt-long discards doublequotes and option values after whitespace
characters
-------------------------+--------------------------------------------------
 Reporter:  evhan        |       Owner:         
     Type:  defect       |      Status:  new    
 Priority:  minor        |   Milestone:  someday
Component:  extensions   |     Version:  4.8.x  
 Keywords:  getopt-long  |  
-------------------------+--------------------------------------------------
 getopt-long contains logic for handling doublequote-wrapped option values.
 However, this interferes with option values containing internal
 doublequotes and makes it impossible to pass arguments that explicitly
 include surrounding doublequotes. I believe argument quoting is adequately
 resolved by the shell before option values are ever in CHICKEN's control
 (i.e. in the command-line-arguments parameter), so this logic is
 unnecessary and the attached patch removes it.

 getopt-long also discards any characters in option values after and
 including the first whitespace character (that is, those in srfi-14's
 char-set:blank). This makes it impossible to pass arguments containing
 spaces without intentionally double-quoting them (to activate the
 doublequote-handling logic, which I believe is incorrect as noted above).

 Finally, getopt-long accepts only a small set of characters in option
 values, raising an error on any characters not in that set. I believe this
 is an unnecessary restriction, so the patch removes it as well.

 {{{
 ;;
 ;; Given the following (and assuming a common shell):
 ;;

 (pp (command-line-arguments))
 (pp (getopt-long (command-line-arguments) '((foo (value #t)))))

 ;;
 ;; $ ./test --foo="\"bar\""
 ;; ("--foo=\"bar\"")
 ;; ((@) (foo . "bar"))
 ;;
 ;; $ ./test --foo="bar baz qux"
 ;; ("--foo=bar baz qux")
 ;; ((@) (foo . "bar"))
 ;;
 ;; $ ./test --foo="\"bar baz qux\""
 ;; ("--foo=\"bar baz qux\"")
 ;; ((@) (foo . "bar baz qux"))
 ;;
 ;; $ ./test --foo="\"bar baz\" qux"
 ;; ("--foo=\"bar baz\" qux")
 ;; ((@) (foo . "bar baz"))
 ;;
 ;; $ ./test --foo='bar"baz"qux'
 ;; ("--foo=bar\"baz\"qux")
 ;; ((@) (foo . "barbazqux"))
 ;;
 ;; $ ./test --foo='bar+baz=qux'
 ;; ("--foo=bar+baz=qux")
 ;; Error: (long-option-value) invalid option character: #\+
 ;;
 }}}

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/1012>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]