Skip to content

Commit 1e648bd

Browse files
committed
core: Export arrays with Unit Separator, not NUL
After #107, in which I decided to use the ASCII Unit Separator ($'\x1f') to delimit array elements for `@go.array_printf` because doing so with NUL ($'\0') wasn't working, it seemed a good idea to switch the `_GO_CMD_NAME` and `_GO_CMD_ARGV` export mechanism to use the Unit Separator as well.
1 parent d6dc9fc commit 1e648bd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

go-core.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ declare -r -x _GO_CMD="${_GO_CMD:=$0}"
105105
# _GO_CMD.
106106
#
107107
# When exported to scripts not written in bash, the array is converted to a
108-
# string with the components delimited by the ASCII NUL character ($'\0').
108+
# string with the components delimited by the ASCII Unit Separator ($'\x1f').
109109
declare -x _GO_CMD_NAME=
110110

111111
# The array of command line arguments for the ./go command after _GO_CMD_NAME.
112112
#
113113
# When exported to scripts not written in bash, the array is converted to a
114-
# string with the arguments delimited by the ASCII NUL character ($'\0').
114+
# string with the arguments delimited by the ASCII Unit Separator ($'\x1f').
115115
declare -x _GO_CMD_ARGV=
116116

117117
# The directory in which plugins are installed.
@@ -290,7 +290,7 @@ _@go.run_command_script() {
290290
else
291291
if [[ -z "$_GO_CMD_NAME" ]]; then
292292
local origIFS="$IFS"
293-
local IFS=$'\0'
293+
local IFS=$'\x1f'
294294
_GO_CMD_NAME="${__go_cmd_name[*]}"
295295
_GO_CMD_ARGV="$*"
296296
IFS="$origIFS"

tests/vars.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ quotify_expected() {
115115
run "$TEST_GO_SCRIPT" test-command test-subcommand foo bar 'baz quux' xyzzy
116116
assert_success
117117
assert_lines_equal "_GO_CMD: $TEST_GO_SCRIPT" \
118-
"_GO_CMD_ARGV: foo"$'\0'"bar"$'\0'"baz quux"$'\0'"xyzzy" \
119-
"_GO_CMD_NAME: test-command"$'\0'"test-subcommand" \
118+
$'_GO_CMD_ARGV: foo\x1fbar\x1fbaz quux\x1fxyzzy' \
119+
$'_GO_CMD_NAME: test-command\x1ftest-subcommand' \
120120
"_GO_CORE_DIR: $_GO_CORE_DIR" \
121121
"_GO_CORE_URL: $_GO_CORE_URL" \
122122
"_GO_CORE_VERSION: $_GO_CORE_VERSION" \

0 commit comments

Comments
 (0)