When we finished last time, I’d just run a simple bash script with some surprising output.
$ ./provision.sh --XISTS=--false resource group exists
-- show up at the start of the line is odd - where do those characters come from? I expected to see
-- at the end of the line, not the start.
-- showing up at the start of the line is actually written last, overwriting the initial
It turns out that the
az command is returning six characters, not five!
false, it is returning
false\r - the expected string, with an extra trailing carriage return character.
Searching online, I found a clue that led me to the root cause of my pain.
$ which az /mnt/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin/az
I was (quite accidentally!) running the Windows version of az, which naturally was writing CRLF (
\r\n) at the end of each line of output, instead of the simple LF (
\n) expected by Linux.
On the one hand, it’s kind of nice to have things so smoothly integrated that the Windows version of the Azure CLI works for most uses even from Linux.
On the other hand, I did spend a couple of hours doubting my ability to write a simple bash script because even the simple things didn’t appear to work.
On the gripping hand, installing the Linux version of the Azure CLI was as simple as
sudo apt install azure-cli.
$ which az /usr/bin/az
And now everything works.