From 3b62cf9bd0f3f44bb0dbd9ed121827dc619a53c2 Mon Sep 17 00:00:00 2001 From: lxoliva Date: Tue, 24 Mar 2009 20:30:52 +0000 Subject: [PATCH] =?utf8?q?Fix=20broken=20sed=20scripts=20when=20using=20da?= =?utf8?q?sh's=20built-in=20echo,=20reported=20by=20Rub=C3=A9n=20Rodr?= =?utf8?q?=C3=ADguez=20P=C3=A9rez.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.fsfla.org/svn/fsfla/software/linux-libre/scripts@4796 559672b5-ba27-0410-b829-e8f1faed8b1b --- deblob-check | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/deblob-check b/deblob-check index bf3414c16c3..e1bdb0dd0af 100755 --- a/deblob-check +++ b/deblob-check @@ -1,6 +1,6 @@ #! /bin/sh -# deblob-check version 2009-03-19 +# deblob-check version 2009-03-24 # Inspired in gNewSense's find-firmware script. # Written by Alexandre Oliva @@ -226,6 +226,25 @@ case ${LANG+set} in set) LANG=C; export LANG;; esac rm="rm -f" + +for echo in 'echo' 'printf %s\n'; do + case `$echo '\nx'` in + '\nx') break;; + esac +done +case `$echo '\nx'` in +'\nx') ;; *) echo Cannot find out what echo to use >&2; exit 1;; +esac + +for echo_n in "echo -n" "printf %s"; do + case `$echo_n '\na'; $echo_n '\nb'` in + '\na\nb') break;; + esac +done +case `$echo_n a; $echo_n b` in +'ab') ;; *) echo Cannot find out an echo -n equivalent to use >&2; exit 1;; +esac + case $1 in --save-scripts | -S) shift @@ -2183,7 +2202,7 @@ g; sedmain=" /^$/N; -/^[\n]\?;[/][*]\\(end .*\\)\\?[*][/];$/{ +/^[\\n]\\?;[/][*]\\(end .*\\)\\?[*][/];$/{ $4; d; } @@ -2211,7 +2230,7 @@ H; g; $4 $v:read all -s/^\\(;[/][*]begin [^\n]*[\\n]\\)*//; +s/^\\(;[/][*]begin [^\\n]*[\\n]\\)*//; s/\\($bol[\n]\?;[/][*]\\(end [^\\n]*\\)\\?[*][/];\\)*$//; $v:???!blobfast /$blobfast/!b clean; @@ -2742,7 +2761,7 @@ check () { # falsepos matches to files that match it. addx () { if test -n "$1"; then - echo -n "\\|$1" >> $falsepos_name + $echo_n "\\|$1" >> $falsepos_name fi } @@ -2751,7 +2770,7 @@ check () { # the falseneg matches to files that match it. badx () { if test -n "$1"; then - echo -n "\\|$1" >> $falseneg_name + $echo_n "\\|$1" >> $falseneg_name fi } @@ -2819,10 +2838,10 @@ check () { esac # Then run through the selected action. - if test "$rm" != "rm -f" || test ! `echo "$sedmain" | wc -c` -lt 1024; then + if test "$rm" != "rm -f" || test ! `$echo "$sedmain" | wc -c` -lt 1024; then scriptname=`mktemp -t deblob-check-sedmain-XXXXXX` tempfiles="$tempfiles $scriptname" - echo "$sedmain" > $scriptname + $echo "$sedmain" > $scriptname cmd="sed -n -f \"$scriptname\"" else cmd='sed -n "$sedmain"' -- 2.31.1