git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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/  |
>
Previous: Uwe Kleine-König
Message 3 of 3 in “[TopGit PATCHv2] provide global temporary directory”
  1. Bert WesargOct 9, 2010
  2. Uwe Kleine-KönigOct 9, 2010
  3. Bert WesargOct 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.