Skip to content

Instantly share code, notes, and snippets.

@termie
Last active November 10, 2015 11:03
Show Gist options
  • Save termie/e79b79a1328bcb0b4666 to your computer and use it in GitHub Desktop.
Save termie/e79b79a1328bcb0b4666 to your computer and use it in GitHub Desktop.
WTF: the case of the missing N
--- a/restore_fixtures.sh
+++ b/restore_fixtures.sh
@@ -65,7 +65,8 @@ restore_to_mongo() {
local etcd_key="/services/mongodb"
echo "etcd key: $etcd_key"
- local host="$(sudo etcdctl ls --recursive $etcd_key | cut -d/ -f4)"
+ local host=$(sudo etcdctl ls --recursive "$etcd_key" | cut -d/ -f4)
local dump="$work_dir/dump/wercker"
# First version results in the command with no "n":
# etcd key: /services/mongodb
# root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/etcdctl ls --recursive /services/mo godb
# Second version results in:
# etcd key: /services/mongodb
# root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/etcdctl ls --recursive /services/mongodb
# Now I agree the second version is more correct but... just removing an "n"? What?
# I tried removing the --recursive and it still only removed the N so it isn't positional.
@termie
Copy link
Author

termie commented Nov 10, 2015

trying to generate a test case i ran into "IFS=$'\n\t'" which somehow got turned into "IFS=$'nt'" in the output script, so mystery solved BUT AT WHAT COST

@termie
Copy link
Author

termie commented Nov 10, 2015

it had the escapes removed by "read" which needed "-r" passed to it to prevent that behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment