Skip to content

Commit

Permalink
scripts: Fix the used sed commands at the end of retdec-decompiler.sh…
Browse files Browse the repository at this point in the history
… to work on macOS (#257).

The original commands failed with the following error on macOS:

    sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'
    sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'

The reason why the commands failed is that when using the -i parameter of sed
on macOS, you need to specify an extension of the backup file. If you do not
want to create a backup file, you have to pass the empty string. On Linux,
using just -i without any extension suffices.

The new sed command should work on Linux, macOS, and Windows, without a need to
install gnu-sed on macOS.
  • Loading branch information
s3rvac authored and Michal Bandzi committed Apr 9, 2018
1 parent c7bba15 commit 4f027d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/retdec-decompiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,9 @@ fi
# Remove trailing whitespace and the last redundant empty new line from the
# generated output (if any). It is difficult to do this in the back-end, so we
# do it here.
sed -i 's/[ \t]*$//' "$OUT"
sed -i '$ { /^$/ d}' "$OUT"
# Note: When modifying the command below, ensure that it works also on macOS as
# its sed differs from the GNU sed.
sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' -e 's/[[:space:]]*$//' -i'' -- "$OUT"

# Colorize output file.
if [ "$COLOR_IDA" ]; then
Expand Down

0 comments on commit 4f027d7

Please sign in to comment.