Closed dwlf closed 9 years ago
This isn't an sh script though, why are we invoking it as sh? If we want it to be a proper sh script, there's a lot more that's wrong with it.
That is an excellent question @rmustacc. @trentm thoughts?
I've confirmed that this change works when invoked with 'sh sdc-docker-setup.sh' on:
Sure, it works a bit when sh is actually bash. Unfortunately sh is not always bash (see, eg. smartos, debian, *BSD, etc.). An analysis as to why this change works is necessary and likely will need to be in a comment, as moving the assignment into the if in shell scripting is not generally done stylistically.
My first choice would be to update docs to invoke with 'bash' and kill this pull request.
Other than the if hack, I haven't found another way for the the invalid option from ssh-keygen -E md5 -l -f "$sshPubKeyPath" 2> /dev/null
not to exit the function and result in the empty assignment sshKeyId=
.
I haven't explored trapping, but my strong preference will be to update docs to invoke with bash
.
+1 to changing docs to say invoke with bash
If we want to support with just vanilla sh
, then that should be separate work (with test cases).
Not yet tested on recent version of OpenSSH.