New answers tagged bash
0
Consider using a different language
Prompted by a comment, I chose to re-implement in Python. This has a couple of advantages:
No external dependencies (xxd isn't part of a default Debian or Ubuntu system)
Perhaps portable to our peer teams using non-Linux platforms.
I didn't do anything to ensure consistent time zone handling, because my team are all in ...
8
Some suggestions:
#!/usr/bin/env bash is a more portable shebang line.
I would use long options for set and xxd for readability. So set -o errexit -o nounset -o pipefail and xxd -revert -plain.
If you quote the array members you can easily use full names.
In case any remote workers are in another time zone offset you'll want to use a fixed one, such as TZ=...
4
Building on Toby's excellent answer, this offers 2 alternate ways to parse the options.
#!/usr/bin/env bash
readonly PROGRAM=${0##*/}
readonly USAGE=$(cat <<END_USAGE
Usage: $PROGRAM [FILE]...
By default file(s) will be extracted to the working directory.
OPTIONS
-d, --directory, eg. nzip [file] [-d directory]
END_USAGE
)
die() { printf '%s\n' ...
5
I'm not sure why we have #!/bin/bash - it looks like plain, portable #!/bin/sh would be fine here.
Things I immediately like include the good error handling, using &2 for error messages and exiting non-zero.
All the tar commands can be combined, as tar is able (with -a) to automatically identify any compression scheme it handles.
As there's no need to ...
0
Elastic Beanstalk configuration using ebextensions container_commands combining leader_only and test
It turns out there is an environment variable called EB_IS_COMMAND_LEADER which can be used in a test. See e.g. this post on AWS forums.
So, the two container commands from the OP can be replaced by this:
container_commands:
0100_execute_command_on_leader_only_but_never_on_worker:
command: foo bar
test: '[[ $ENV_NAME != "worker" &&...
Top 50 recent answers are included
Related Tags
bash × 698linux × 163
shell × 161
beginner × 86
performance × 38
git × 37
file-system × 35
installer × 34
awk × 30
sed × 28
console × 27
sh × 26
macos × 24
security × 23
unix × 23
python × 18
parsing × 18
amazon-web-services × 14
mysql × 13
regex × 13
networking × 13
wordpress × 12
ssh × 12
c × 11
strings × 10