Skip to content

Commit b93a952

Browse files
committed
Fix commercialhaskell#3091 Improve help with shell processing of arguments
1 parent e47189c commit b93a952

File tree

2 files changed

+108
-1
lines changed

2 files changed

+108
-1
lines changed

doc/build_command.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,69 @@ Specified arguments are separated by spaces. Arguments can be unquoted (if they
472472
do not contain space or `"` characters) or quoted (`""`). Quoted arguments can
473473
include 'escaped' characters, escaped with an initial `\` character.
474474

475+
Account may need to be taken of the shell's approach to the processing of
476+
command line arguments. For example, to pass `'a single quoted string'`:
477+
478+
=== "Unix-like (Bash or Zsh)"
479+
480+
In Bash, or Zsh (if `RC_QUOTES` option not set):
481+
482+
`stack bench --benchmark-arguments \"\''a single quoted string'\'\"`
483+
484+
Outside of single quotes, `\"` escapes a double quote and `\'` escapes a
485+
single quote. The content of single quotes is taken literally, but cannot
486+
contain a single quote.
487+
488+
In Zsh (if `RC_QUOTES` option set):
489+
490+
`stack bench --benchmark-arguments '"''a single quoted string''"'`
491+
492+
The content of single quotes is taken literally. Within single quotes, `''`
493+
escapes a single quote.
494+
495+
=== "Windows (PowerShell)"
496+
497+
`stack bench --benchmark-arguments '"''a single quoted string''"'`
498+
499+
The content of single quotes is taken literally. Within single quotes, `''`
500+
escapes a single quote.
501+
475502
### `--exec` option
476503

477-
`stack build --exec "<command> [<argument(s)>]"` will run the specified command
504+
`stack build --exec '<command> [<argument(s)>]'` will run the specified command
478505
after a successful build.
479506

480507
Specified arguments are separated by spaces. Arguments can be unquoted (if they
481508
do not contain space or `"` characters) or quoted (`""`). Quoted arguments can
482509
include 'escaped' characters, escaped with an initial `\` character.
483510

511+
Account may need to be taken of the shell's approach to the processing of
512+
command line arguments. For example, to pass `'a single quoted string'`:
513+
514+
=== "Unix-like (Bash or Zsh)"
515+
516+
In Bash, or Zsh (if `RC_QUOTES` option not set):
517+
518+
`stack build --exec '<command> '\"\''a single quoted string'\'\"`
519+
520+
Outside of single quotes, `\"` escapes a double quote and `\'` escapes a
521+
single quote. The content of single quotes is taken literally, but cannot
522+
contain a single quote.
523+
524+
In Zsh (if `RC_QUOTES` option set):
525+
526+
`stack build --exec '<command> "''a single quoted string''"'`
527+
528+
The content of single quotes is taken literally. Within single quotes, `''`
529+
escapes a single quote.
530+
531+
=== "Windows (PowerShell)"
532+
533+
`stack build --exec '<command> "''a single quoted string''"'`
534+
535+
The content of single quotes is taken literally. Within single quotes, `''`
536+
escapes a single quote.
537+
484538
### `--test-arguments`, `--ta` option
485539

486540
`stack build --test --test-arguments=<argument(s)>` will pass the specified
@@ -491,6 +545,33 @@ Specified arguments are separated by spaces. Arguments can be unquoted (if they
491545
do not contain space or `"` characters) or quoted (`""`). Quoted arguments can
492546
include 'escaped' characters, escaped with an initial `\` character.
493547

548+
Account may need to be taken of the shell's approach to the processing of
549+
command line arguments. For example, to pass `'a single quoted string'`:
550+
551+
=== "Unix-like (Bash or Zsh)"
552+
553+
In Bash, or Zsh (if `RC_QUOTES` option not set):
554+
555+
`stack test --test-arguments \"\''a single quoted string'\'\"`
556+
557+
Outside of single quotes, `\"` escapes a double quote and `\'` escapes a
558+
single quote. The content of single quotes is taken literally, but cannot
559+
contain a single quote.
560+
561+
In Zsh (if `RC_QUOTES` option set):
562+
563+
`stack bench --benchmark-arguments '"''a single quoted string''"'`
564+
565+
The content of single quotes is taken literally. Within single quotes, `''`
566+
escapes a single quote.
567+
568+
=== "Windows (PowerShell)"
569+
570+
`stack test --test-arguments '"''a single quoted string''"'`
571+
572+
The content of single quotes is taken literally. Within single quotes, `''`
573+
escapes a single quote.
574+
494575
## Flags affecting GHC's behaviour
495576

496577
### `--[no-]executable-profiling` flag

doc/exec_command.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,29 @@ Specified GHC RTS flags and options are separated by spaces. Items can be
3838
unquoted (if they do not contain space or `"` characters) or quoted (`""`).
3939
Quoted items can include 'escaped' characters, escaped with an initial `\`
4040
character.
41+
42+
Account may need to be taken of the shell's approach to the processing of
43+
command line arguments. For example, to pass `'a single quoted string'`:
44+
45+
=== "Unix-like (Bash or Zsh)"
46+
47+
In Bash, or Zsh (if `RC_QUOTES` option not set):
48+
49+
`stack exec <command> -- \''a single quoted string'\'`
50+
51+
Outside of single quotes, `\'` escapes a single quote. The content of single
52+
quotes is taken literally, but cannot contain a single quote.
53+
54+
In Zsh (if `RC_QUOTES` option set):
55+
56+
`stack exec <command> -- '''a single quoted string'''`
57+
58+
The content of single quotes is taken literally. Within single quotes, `''`
59+
escapes a single quote.
60+
61+
=== "Windows (PowerShell)"
62+
63+
`stack exec <command> -- '''a single quoted string'''`
64+
65+
The content of single quotes is taken literally. Within single quotes, `''`
66+
escapes a single quote.

0 commit comments

Comments
 (0)