Skip to content

Commit

Permalink
* updated mincheader to handle spaces in filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjanke committed Aug 3, 2012
1 parent d6dbcda commit 524ade8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2012-08-03 Andrew L Janke <[email protected]>
* progs/mincheader/mincheader: fixed to handle files with spaces

2012-06-21 Andrew L Janke <[email protected]>
* added mincblob.man1 and updated configure.ac and Makefile.am

Expand Down
17 changes: 8 additions & 9 deletions progs/mincheader/mincheader
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ set -o nounset

# simple little function to emulate perl's die();
die () {
echo >&2 $@
echo >&2 "$@"
echo ""
exit 1
}
Expand All @@ -83,7 +83,7 @@ header_opts='-header_only'
header_only=yes
while [ $# -gt 0 ]
do
case $1 in
case "$1" in
-h|-he|-hel|-help)
echo $usage;
echo ""
Expand All @@ -104,28 +104,27 @@ done

# only allow one input file and check for it
[ $# -eq 1 ] || die $usage
[ -f $1 ] || die "$me: no such file $1"

[ -f "$1" ] || die "$me: no such file '$1'"

tmpfile="$tmpdir/mincheader-$$-tmp"

# For a compressed file, dump header only unless directed otherwise
dumpfile=`mincexpand $1 $tmpfile -name_only $header_opts`
if [ $dumpfile = $tmpfile -a $header_only = yes ]
dumpfile=`mincexpand "$1" $tmpfile -name_only $header_opts`
if [ "$dumpfile" = $tmpfile -a $header_only = yes ]
then
mincdump -h $dumpfile
mincdump -h "$dumpfile"
else
# Get variables names (excluding image): remove leading "image", remove word
# "image", collapse multiple blanks to one, remove leading blanks, remove
# trailing blanks, replace blanks with commas
vars=`mincinfo -varnames $dumpfile | \
vars=`mincinfo -varnames "$dumpfile" | \
sed -e 's/^image //g' \
-e 's/ image / /g' \
-e 's/ */ /g' \
-e 's/^ //' \
-e 's/ $//' \
-e 's/ /,/g'`

[ x$vars = x ] || mincdump -v "$vars" $dumpfile
[ x$vars = x ] || mincdump -v "$vars" "$dumpfile"
fi

0 comments on commit 524ade8

Please sign in to comment.