1

Not a Mac guy here.

Many months ago I wrote the following command in a bash script on a Mac.

export AUTH=$(echo -n "$USER_ID:$SVC_KEY" | base64)

It worked as you would expect, the base64 of "value_of_USER_ID:value_of_SVC_KEY". Months later I run it and the output is the base64 of "-n value_of_USER_ID:value_of_SVC_KEY".

InB4 yes, it took me a while to figure out that this was the problem :-)

What setting changed to cause the "-n " to be included? How do I change it back?

Thanks!

citizen
  • 353
  • 3
  • 13

1 Answers1

3

It sounds like you may have changed your shell from bash to sh. In sh the way to echo without a newline is to end it with \c:

export AUTH=$(echo "$USER_ID:$SVC_KEY\c" | base64)

But a more portable way to print without a newline is to use printf:

export AUTH=$(printf "%s" "$USER_ID:$SVC_KEY" | base64)

See 'echo' without newline in a shell script

Barmar
  • 741,623
  • 53
  • 500
  • 612