Re: [TopGit PATCHv2] provide global temporary directory
- From
Bert Wesarg <bert.wesarg@googlemail.com>
- Date
- Oct 10, 2010, 07:47 UTC
- Message-ID
- <AANLkTikuEa6TQpEnv=0y3v18W9H8sC4SQ+5vdTvBW7LF@mail.gmail.com>
- In-Reply-To
- <20101009215302.GR29673@pengutronix.de>
2010/10/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
Show 5 quoted lines
> On Sat, Oct 09, 2010 at 11:41:47PM +0200, Bert Wesarg wrote: >> +# get_temp NAME [-d] > I like your patch in general, but would prefer to have > > # get_temp [-d] NAME
But that would complicate the argument evaluation, wouldn't it:
get_temp()
{
if [ $# -eq 2 ]; then
mktemp $1 "$tg_tmp_dir/$2.XXXXXX"
else
mktemp "$tg_tmp_dir/$1.XXXXXX"
fi
}This and the functions with [-i | -w] are internal and won't be called by the user, so we have full control over the calling convention and should make it easy for us. And putting the optional argument at the end is easy. I should probably remove the die call in cat_file, because that would be an programmer error not an user error.
Show 7 quoted lines
>
>> +# creates a new temporary file (or directory with -d) in the global
>> +# temporary directory $tg_tmp_dir with pattern prefix NAME
>> +get_temp()
>> +{
>> + mktemp ${2-} "$tg_tmp_dir/$1.XXXXXX"
> Does the - makes any difference? If yes, is it portable (enough)?For me its an indicator, that it doesn't matter whether $2 was given or not. Also you could run under set -u without error. But I don't do this.
It's in POSIX [1].
Bert
[1] Statement given without interpretation.
Show 7 quoted lines
> Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-König | > Industrial Linux Solutions | http://www.pengutronix.de/ | >