mktemp + tempfile wrapper instead of lfs-utils

richard at nezumi.plus.com richard at nezumi.plus.com
Thu Jun 5 01:49:39 PDT 2003


On 2003-06-04 22:56:02 +0000, Tushar Teredesai wrote:
> 
> Attaching a script for Option 2 above. Please note that the script is 
> not heavily tested and may not be the most optimal. So would appreciate 
> feedback. Probably will submit the script to mktemp maintainer if he 
> would like to include it in the mktemp tarball.
> 
1) tempfile --version -m 000

2) <nitpick>
All those echo's in the usage look a bit excessive. How about one of
these:
echo "\
Useage:

..."
cat <<-EOF
	usage:

	...
	EOF
</nitpick>

3) There is no need to duplicate $# and $1 with $n, $a and $i:

quote="'\"'\"'"
while [ $# != 0 ]; do
        case "$1" in
        # Chmod request
        -m|--mode)
                shift
                MODE="$1";;
        --mode=*)
                MODE="${1#--mode}";;
...
	esac
	shift
done

4) Assume someone is out to get you. Quote everything:

> 	--mode=*)
> 		i=${a/\-\-mode=}
...
> 	-d|--directory)
> 		args="$args -p $1"
		args="$args -p '${1//\'/$quote}'"

If you can find a way to:
	quote="'\"'\"'"
	x="'${y//\'/$quote}'"
without using $quote, I would like to hear it.
Are we looking at a bug in bash's quote removal here?

5) Someone will make mktemp output spaces:

> file=`mktemp $args`
  file="$(mktemp $args)"

6) <nitpick>
> if [ ! -z "$MODE" ]
  if [ -n "$MODE" ]
</nitpick>

7) And quote everything else:

 	#echo "chmod \"$MODE\" \"$file\""
 	chmod "$MODE" "$file" || (rm -f "$file" ; exit 1)
fi
echo "$file"


This reply is near off-topic for lfs-dev. Replies to this should
probably be on lfs-chat.


Richard
-- 
If you think you program is idiot proof, you have not trusted it with
a qualified idiot.

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list