Skip to content

Commit

Permalink
[oil-language] Change the default for echo -sep to '\n'.
Browse files Browse the repository at this point in the history
The default is to generate "testdata", i.e. this makes sense:

echo 3 1 2 | sort -n

But -sep '' and -sep ' ' are expected to be common invocations.
  • Loading branch information
Andy Chu committed Aug 22, 2019
1 parent 3c7893f commit a78949b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 2 additions & 3 deletions doc/oil-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,8 @@ var s = sorted(ARGV)
`shopt -s simple_echo` changes the `echo` builtin to accept the following long
flags, as well as the `--` separator between flags and args.

- `-sep`: Characters to separate args to `echo`. (Default: empty string)
- `-end`: Characters to terminate the whole `echo` invocation. (Default:
newline)
- `-sep`: Characters to separate each argument. (Default: newline)
- `-end`: Characters to terminate the whole invocation. (Default: newline)
- `-n`: A synonym for `-end ''`.

#### push
Expand Down
8 changes: 4 additions & 4 deletions osh/builtin_pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,12 @@ def __call__(self, arg_vec):
ECHO_SPEC.ShortFlag('-n')

OIL_ECHO_SPEC = args.OilFlags()
OIL_ECHO_SPEC.Flag('-sep', args.Str, default='',
help='Characters to separate args')
OIL_ECHO_SPEC.Flag('-sep', args.Str, default='\n',
help='Characters to separate each argument')
OIL_ECHO_SPEC.Flag('-end', args.Str, default='\n',
help='Characters to terminate the echo invocation')
help='Characters to terminate the whole invocation')
OIL_ECHO_SPEC.Flag('-n', args.Bool, default=False,
help='Omit newline')
help="Omit newline (synonym for -end '')")


class Echo(object):
Expand Down
14 changes: 13 additions & 1 deletion spec/builtin-oil.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ argv.py @a
shopt -s all:oil
var a = @('a b' 'c d')
echo @a
echo .
echo -- @a
echo .

echo -sep '' -end '' @a; echo
echo .

echo -sep '_' -- @a
echo -sep '_' -end $' END\n' -- @a
Expand All @@ -33,9 +38,16 @@ echo --sep '_' --end $' END\n' -- @a
echo -n x
echo -n y
echo

## STDOUT:
a b
c d
.
a b
c d
.
a bc d
a bc d
.
a b_c d
a b_c d END
a b_c d END
Expand Down

0 comments on commit a78949b

Please sign in to comment.