run_and_print_on_failure(): fixed mktemp not found on AIX#1834
Conversation
| { | ||
| local temp_output_file | ||
| temp_output_file=$(mktemp) | ||
| if command mktemp; then |
There was a problem hiding this comment.
in functions here there is already func_mktemp(). I think you should move this AIX case there and use that function instead if that fits the bill.
There was a problem hiding this comment.
However, it only works as mktemp -d
# Only works as mktemp -d /path/to/tmpdir.XXXXThere was a problem hiding this comment.
yeah, I feel like I have worked around this in other places too :( so maybe let's look a little harder and make a compatibility layer of some sort ;)
There was a problem hiding this comment.
maybe it would be better to adjust the function we have and augment with what I worked up for cf-support for mktemp -d at https://github.com/cfengine/core/blob/master/misc/cf-support#L116
make_temp_dir()
{
if command -v mktemp >/dev/null && [ "$OS" != "hpux" ]; then
mktemp -d
else
# shellcheck disable=SC2021
# ^^ legacy/POSIX requires square brackets
_tmp="/tmp/`LC_CTYPE=C tr -dc "[A-Z][a-z][0-9]" </dev/urandom | dd count=1 bs=8 2>/dev/null`"
mkdir "$_tmp"
echo "$_tmp"
fi
}
Probably though, the minimal and recommended change would be to add 2>/dev/null in your existing code.
| if command mktemp; then | |
| if command -v mktemp 2>/dev/null; then |
You want -v so it doesn't run the command and probably 2>/dev/null to keep things quiet. :)
craigcomstock
left a comment
There was a problem hiding this comment.
just add -v and 2>/dev/null to "command mktemp" and think this is awesome. 👍
| { | ||
| local temp_output_file | ||
| temp_output_file=$(mktemp) | ||
| if command mktemp; then |
There was a problem hiding this comment.
maybe it would be better to adjust the function we have and augment with what I worked up for cf-support for mktemp -d at https://github.com/cfengine/core/blob/master/misc/cf-support#L116
make_temp_dir()
{
if command -v mktemp >/dev/null && [ "$OS" != "hpux" ]; then
mktemp -d
else
# shellcheck disable=SC2021
# ^^ legacy/POSIX requires square brackets
_tmp="/tmp/`LC_CTYPE=C tr -dc "[A-Z][a-z][0-9]" </dev/urandom | dd count=1 bs=8 2>/dev/null`"
mkdir "$_tmp"
echo "$_tmp"
fi
}
Probably though, the minimal and recommended change would be to add 2>/dev/null in your existing code.
| if command mktemp; then | |
| if command -v mktemp 2>/dev/null; then |
You want -v so it doesn't run the command and probably 2>/dev/null to keep things quiet. :)
…tion Having the basename printed along side the error message will aid in debugging by giving you a clue as to where the fatal error happened. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Ticket: ENT-13158 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Ticket: ENT-13158
Signed-off-by: Lars Erik Wik lars.erik.wik@northern.tech
Build on AIX & Ubuntu with no tests
