Hi, I thought I'd have a look through the d-i code for instances of: cat ... | to see if I could find any code with room for improvement, and came up with the attached patch. Any comments before I commit these? (along with relevant changelog entries, of course, and removing the comment about removing a space from the disk name that's only there to annotate the patch) Cheers, Phil.
diff --git a/packages/arch/powerpc/yaboot-installer/debian/postinst b/packages/arch/powerpc/yaboot-installer/debian/postinst index 0f3d0ed..7a34dd5 100644 --- a/packages/arch/powerpc/yaboot-installer/debian/postinst +++ b/packages/arch/powerpc/yaboot-installer/debian/postinst @@ -439,7 +439,7 @@ enablecdboot EOF if [ -s "$extraglobals" ]; then - cat "$extraglobals" | writeyabootconf + writeyabootconf < "$extraglobals" rm -f "$extraglobals" fi @@ -477,7 +477,7 @@ EOF fi if [ -s "$extraimages" ]; then - cat "$extraimages" | writeyabootconf + writeyabootconf < "$extraimages" rm -f "$extraimages" fi diff --git a/packages/choose-mirror/sort-templates b/packages/choose-mirror/sort-templates index 32b49d9..9debc93 100755 --- a/packages/choose-mirror/sort-templates +++ b/packages/choose-mirror/sort-templates @@ -34,7 +34,7 @@ for template in $templates; do for file in list.*; do [ -e "$file" ] || continue - [ $(cat "$file" | wc -l) -gt 1 ] || continue + [ $(wc -l "$file") -gt 1 ] || continue lang=${file#list.} unilang=$(grep "^$lang.* UTF-8" /usr/share/i18n/SUPPORTED | \ diff --git a/packages/debian-installer-utils/chroot-setup.sh b/packages/debian-installer-utils/chroot-setup.sh index c620ed9..2aa3328 100644 --- a/packages/debian-installer-utils/chroot-setup.sh +++ b/packages/debian-installer-utils/chroot-setup.sh @@ -108,9 +108,7 @@ chroot_cleanup () { # Undo the mounts done by the packages during installation. # Reverse sorting to umount the deepest mount points first. # Items with count of 1 are new. - for dir in $( (cat /tmp/mount.pre /tmp/mount.pre; mountpoints ) | \ - sort -r | uniq -c | grep "^[[:space:]]*1[[:space:]]" | \ - sed "s/^[[:space:]]*[0-9][[:space:]]//"); do + for dir in $(mountpoints | sort -r /tmp/mount.pre /tmp/mount.pre - | uniq -u); do if ! umount $dir; then logger -t $0 "warning: Unable to umount '$dir'" fi diff --git a/packages/floppy-retriever/debian/load-floppy.postinst b/packages/floppy-retriever/debian/load-floppy.postinst index 3d7e1da..6b3e61e 100755 --- a/packages/floppy-retriever/debian/load-floppy.postinst +++ b/packages/floppy-retriever/debian/load-floppy.postinst @@ -41,7 +41,8 @@ while true; do label="" mountfloppy if [ -e $FLOPPYMNT/disk.lbl ]; then - label=$(cat $FLOPPYMNT/disk.lbl | grep "^Label" | sed "s/Label://") + label=$(sed -n "s/^Label: *//p" $FLOPPYMNT/disk.lbl) + # N.B. This is a slight modification, in that it eats any space(s) before the disk name -- I'd have thought that's an improvement fi umount $FLOPPYMNT diff --git a/packages/installation-report/report-hw b/packages/installation-report/report-hw index 5bc69b0..352e72a 100755 --- a/packages/installation-report/report-hw +++ b/packages/installation-report/report-hw @@ -10,7 +10,7 @@ addinfo () { addfile () { if [ -r "$1" ]; then - cat "$1" | addinfo "$1" + addinfo "$1" < "$1" fi } diff --git a/packages/localechooser/get-SUPPORTED b/packages/localechooser/get-SUPPORTED index 5755cd6..2501bb2 100755 --- a/packages/localechooser/get-SUPPORTED +++ b/packages/localechooser/get-SUPPORTED @@ -5,4 +5,4 @@ set -e [ -r /usr/share/i18n/SUPPORTED ] || exit 1 rm -rf debian/SUPPORTED-short >/dev/null 2>&1 -cat /usr/share/i18n/SUPPORTED | cut -f1 -d ' ' | uniq >debian/SUPPORTED-short +cut -f1 -d ' ' /usr/share/i18n/SUPPORTED | uniq >debian/SUPPORTED-short diff --git a/packages/localechooser/mktemplates.shortlist b/packages/localechooser/mktemplates.shortlist index da59a44..8280d2f 100755 --- a/packages/localechooser/mktemplates.shortlist +++ b/packages/localechooser/mktemplates.shortlist @@ -48,7 +48,7 @@ for LANG in $SHORTLIST_LANGS; do # Next we put the countrycodes in the untranslated shortlist SHORTLIST= - for COUNTRYCODE in $(cat $SHORTLIST_DIR/$LANG.short | cut -f 1) ; do + for COUNTRYCODE in $(cut -f 1 $SHORTLIST_DIR/$LANG.short) ; do SHORTLIST="$SHORTLIST$COUNTRYCODE, " done C_CHOICES=$(echo $EN_CHOICES | sed "s/Choices:/Choices-C:/") diff --git a/packages/localechooser/sort-templates b/packages/localechooser/sort-templates index 302e341..d62be2d 100755 --- a/packages/localechooser/sort-templates +++ b/packages/localechooser/sort-templates @@ -30,7 +30,7 @@ for template in $templates; do for file in list.*; do [ -e "$file" ] || continue - [ $(cat "$file" | wc -l) -gt 1 ] || continue + [ $(wc -l "$file") -gt 1 ] || continue lang=${file#list.} unilang=$(grep "^$lang.* UTF-8" /usr/share/i18n/SUPPORTED | \ diff --git a/packages/partman/partman-basicfilesystems/commit.d/format_basicfilesystems b/packages/partman/partman-basicfilesystems/commit.d/format_basicfilesystems index 6b7d65e..79a5873 100755 --- a/packages/partman/partman-basicfilesystems/commit.d/format_basicfilesystems +++ b/packages/partman/partman-basicfilesystems/commit.d/format_basicfilesystems @@ -77,8 +77,7 @@ for dev in $DEVICES/*; do if [ "$status" = OK ]; then label='' if [ -f $id/label ]; then - label=$(cat $id/label | \ - sed 's/\(................\).*/\1/g') + label=$(cut -c-16 $id/label) fi if [ "$label" ]; then log-output -t partman --pass-stdout \ diff --git a/packages/partman/partman-ext2r0/commit.d/format_ext2r0 b/packages/partman/partman-ext2r0/commit.d/format_ext2r0 index 4878821..8321f9f 100755 --- a/packages/partman/partman-ext2r0/commit.d/format_ext2r0 +++ b/packages/partman/partman-ext2r0/commit.d/format_ext2r0 @@ -64,8 +64,7 @@ for dev in $DEVICES/*; do if [ "$status" = OK ]; then label='' if [ -f $id/label ]; then - label=$(cat $id/label | \ - sed 's/\(................\).*/\1/g') + label=$(cut -c-16 $id/label) fi if [ "$label" ]; then tune2fs -L "$label" $device diff --git a/packages/partman/partman-ext3/commit.d/format_ext3 b/packages/partman/partman-ext3/commit.d/format_ext3 index 7bd39b5..e2302b8 100755 --- a/packages/partman/partman-ext3/commit.d/format_ext3 +++ b/packages/partman/partman-ext3/commit.d/format_ext3 @@ -88,8 +88,7 @@ for dev in $DEVICES/*; do if [ "$status" = OK ]; then label='' if [ -f $id/label ]; then - label=$(cat $id/label | \ - sed 's/\(................\).*/\1/g') + label=$(cut -c-16 $id/label) fi if [ "$label" ]; then log-output -t partman --pass-stdout \ diff --git a/packages/partman/partman-jfs/commit.d/format_jfs b/packages/partman/partman-jfs/commit.d/format_jfs index 626ae25..cc73dc4 100755 --- a/packages/partman/partman-jfs/commit.d/format_jfs +++ b/packages/partman/partman-jfs/commit.d/format_jfs @@ -59,8 +59,7 @@ for dev in $DEVICES/*; do if [ "$code" = 0 ]; then label='' if [ -f $id/label ]; then - label=$(cat $id/label | \ - sed 's/\(................\).*/\1/g') + label=$(cut -c-16 $id/label) fi if [ "$label" ]; then jfs_tune -L "$label" $device diff --git a/packages/partman/partman-reiserfs/commit.d/format_reiserfs b/packages/partman/partman-reiserfs/commit.d/format_reiserfs index ce3787a..dbb7f68 100755 --- a/packages/partman/partman-reiserfs/commit.d/format_reiserfs +++ b/packages/partman/partman-reiserfs/commit.d/format_reiserfs @@ -62,8 +62,7 @@ for dev in $DEVICES/*; do label='' if [ -f $id/label ]; then - label=$(cat $id/label | \ - sed 's/\(................\).*/\1/g') + label=$(cut -c-16 $id/label) fi # Ensure label is quoted correctly if log-output -t partman --pass-stdout \ diff --git a/packages/partman/partman-xfs/commit.d/format_xfs b/packages/partman/partman-xfs/commit.d/format_xfs index 0e3d3bc..cff4c8b 100755 --- a/packages/partman/partman-xfs/commit.d/format_xfs +++ b/packages/partman/partman-xfs/commit.d/format_xfs @@ -53,8 +53,7 @@ for dev in $DEVICES/*; do label='' if [ -f $id/label ]; then - label=$(cat $id/label | \ - sed 's/\(............\).*/\1/g') + label=$(cut -c-12 $id/label) fi code=0 # Ensure label is quoted correctly
Attachment:
signature.asc
Description: Digital signature