Menu

#2329 Only use space or tab to separate arguments

WSL
closed
None
Feature
fixed
IINR_-_Include_In_Next_Release
True
2017-02-01
2017-01-05
Jason Hood
No

Only use space and tab to separate arguments (as Bash does), not all whitespace.
(^K is entered as Ctrl+K and output as the literal character.)

T:\>cat test.c
#include <stdio.h>
int main(int argc, char** argv) { puts(argv[1]); }
T:\>gcc test.c -s -o old.exe
T:\>gcc test.c -s -o new.exe -Lmingwrt-3.22.4-1
T:\>old a^Kb
a
T:\>new a^Kb
a^Kb
1 Attachments

Discussion

  • Keith Marshall

    Keith Marshall - 2017-01-12

    Once again, what bash does is not authoritatively definitive of any standard behaviour; you need to cite the appropriate POSIX reference documentation.

    On balance, I think you may be right; POSIX shells should split argument fields at IFS characters, (which by default are SPC, HT, and LF). This begs the question: should setargv() consider any other characters which may have been added to IFS? The POSIX standard doesn't make this particularly clear, but I don't know of any supposedly POSIX compliant shell which uses anything other than default IFS-whitespace, except when performing word-splitting of command substituted, or shell/environment variable substituted arguments, so perhaps not.

     
  • Jason Hood

    Jason Hood - 2017-01-13

    I'd rather not have LF as a delimiter, as that's the character that caused me to make the patch in the first place (GLOBAL's ctags plugin stopped working, which I eventually tracked down to LF becoming a separator, which neither MSVC nor mingw-w64 do, although it seems Cygwin does; admittedly, I should quote it anyway).

     
  • Keith Marshall

    Keith Marshall - 2017-01-25
    • status: unread --> pending
    • assigned_to: Keith Marshall
    • Type: Bug --> Feature
    • Resolution: none --> fixed
    • Category: Unknown --> IINR_-_Include_In_Next_Release
     
  • Keith Marshall

    Keith Marshall - 2017-01-25

    I've experimented with various shells, on my LMDE box, and can only get IFS word splitting when substituting command output or shell/environment variables; in all other cases, only the ISO-C99 ctype isblank characters serve as argument separators. LF always serves as a command terminator, unless quoted or embedded within one of the afore-mentioned substitutions; (in the latter case it does serve as IFS-whitespace). Consequently, I committed [888d2e], as an alternative to your patch; please confirm if this is satisfactory.

     

    Related

    Commit: [888d2e]

  • Jason Hood

    Jason Hood - 2017-01-26

    Quite satisfactory, thank you.

     
  • Keith Marshall

    Keith Marshall - 2017-02-01
    • status: pending --> closed