Skip to content

Commit

Permalink
Fallback to hexdump if od not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Aug 5, 2019
1 parent 19a9536 commit 3ce1d4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -123,7 +123,7 @@ shellspec is implemented in a pure shell script with a shell built-in commands a

Currently used external (not shell built-in) commands.

- `cat`, `date`, `ls`, `mkdir`, `od`, `rm`, `sleep`, `sort`, `time`
- `cat`, `date`, `ls`, `mkdir`, `od` (or `hexdump` not posix), `rm`, `sleep`, `sort`, `time`
- `ps` (used on systems without procfs, but not required.)
- `kill`, `printf` (used but almost shell built-in.)

Expand Down
8 changes: 6 additions & 2 deletions lib/libexec/binary.sh
Expand Up @@ -2,10 +2,14 @@

# busybox 1.1.3: `-A n`, `-t o1` not supported
# busybox 1.10.2: `od -b` not working properly
if echo | od -t o1 -v >/dev/null 2>&1; then
if od -t o1 -v /dev/null >/dev/null 2>&1; then
od_command() { od -t o1 -v; }
else
od_command() { od -b -v; }
if [ $? -eq 127 ] && hexdump /dev/null >/dev/null 2>&1; then
od_command() { hexdump -b -v; }
else
od_command() { od -b -v; }
fi
fi

octal_dump() {
Expand Down

0 comments on commit 3ce1d4e

Please sign in to comment.