{"thread":{"id":"25406","subject":"[TopGit PATCHv2] provide global temporary directory","startedAt":"2010-10-09T21:41:47Z","lastAt":"2010-10-10T07:47:47Z","messageCount":3,"participants":["Bert Wesarg","Uwe Kleine-König"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"153100","messageId":"d351f9124a96f212fe66ee85b4241753be94ab2b.1286660467.git.bert.wesarg@googlemail.com","threadId":"25406","inReplyTo":null,"subject":"[TopGit PATCHv2] provide global temporary directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-10-09T21:41:47Z","receivedAt":"2010-10-09T21:41:47Z","isPatch":false,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"The standard procedure 'tmp=mktemp; trap \"rm $tmp\" 0' was broken with the\nintroduction of the pager. Which overwrites the trap itself to close and\nremove the pager fifo.\n\nNow tg provides a temp playground and all other temp files should be created\ninside this directory and only this directory will be removed with the exit\ntrap. setup_pager still overwrites the trap, but keeps the rm command from\nthe global temp directory. To simplify this the new function get_temp() is\nprovided.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n hooks/pre-commit.sh |    3 +--\n tg-export.sh        |    3 +--\n tg-info.sh          |    3 +--\n tg-mail.sh          |    4 +---\n tg-patch.sh         |    3 +--\n tg-push.sh          |    3 +--\n tg-summary.sh       |    3 +--\n tg-update.sh        |    3 +--\n tg.sh               |   27 +++++++++++++++++++--------\n 9 files changed, 27 insertions(+), 25 deletions(-)\n\ndiff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh\nindex 4f2f16f..848a929 100644 hooks/pre-commit.sh\n--- a/hooks/pre-commit.sh\n+++ b/hooks/pre-commit.sh\n@@ -95,9 +95,8 @@ BEGIN      { in_hunk = 0; }\n \tdone\n \n # check for repetitions of deps\n-depdir=\"$(mktemp -t -d tg-depdir.XXXXXX)\" ||\n+depdir=\"$(get_temp -d tg-depdir)\" ||\n \tdie \"Can't check for multiple occurrences of deps\"\n-trap \"rm -rf '$depdir'\" 0\n cat_file \"(i):.topdeps\" |\n \twhile read dep; do\n \t\t[ ! -d \"$depdir/$dep\" ] ||\ndiff --git a/tg-export.sh b/tg-export.sh\nindex 6d82d55..921e933 100644 tg-export.sh\n--- a/tg-export.sh\n+++ b/tg-export.sh\n@@ -57,8 +57,7 @@ if [ -z \"$branches\" ]; then\n fi\n \n \n-playground=\"$(mktemp -d -t tg-export.XXXXXX)\"\n-trap 'rm -rf \"$playground\"' EXIT\n+playground=\"$(get_temp tg-export -d)\"\n \n \n ## Collapse driver\ndiff --git a/tg-info.sh b/tg-info.sh\nindex 7d6a34c..10e257e 100644 tg-info.sh\n--- a/tg-info.sh\n+++ b/tg-info.sh\n@@ -51,7 +51,7 @@ fi\n git cat-file blob \"$name:.topdeps\" |\n \tsed '1{ s/^/Depends: /; n; }; s/^/         /;'\n \n-depcheck=\"$(mktemp -t tg-depcheck.XXXXXX)\"\n+depcheck=\"$(get_temp tg-depcheck)\"\n missing_deps=\n needs_update \"$name\" >\"$depcheck\" || :\n if [ -n \"$missing_deps\" ]; then\n@@ -72,6 +72,5 @@ if [ -s \"$depcheck\" ]; then\n else\n \techo \"Up-to-date.\"\n fi\n-rm \"$depcheck\"\n \n # vim:noet\ndiff --git a/tg-mail.sh b/tg-mail.sh\nindex 8167ade..dd4a95a 100644 tg-mail.sh\n--- a/tg-mail.sh\n+++ b/tg-mail.sh\n@@ -34,7 +34,7 @@ if [ -n \"$in_reply_to\" ]; then\n fi\n \n \n-patchfile=\"$(mktemp -t tg-mail.XXXXXX)\"\n+patchfile=\"$(get_temp tg-mail)\"\n \n $tg patch \"$name\" >\"$patchfile\"\n \n@@ -54,6 +54,4 @@ people=\n # NOTE: git-send-email handles cc itself\n eval git send-email $send_email_args \"$people\" \"$patchfile\"\n \n-rm \"$patchfile\"\n-\n # vim:noet\ndiff --git a/tg-patch.sh b/tg-patch.sh\nindex 7bafdfe..68efcf0 100644 tg-patch.sh\n--- a/tg-patch.sh\n+++ b/tg-patch.sh\n@@ -51,7 +51,7 @@ echo\n [ -n \"$(git grep $diff_opts '^[-]--' ${diff_committed_only:+\"$name\"} -- \".topmsg\")\" ] || echo '---'\n \n # Evil obnoxious hack to work around the lack of git diff --exclude\n-git_is_stupid=\"$(mktemp -t tg-patch-changes.XXXXXX)\"\n+git_is_stupid=\"$(get_temp tg-patch-changes)\"\n git diff --name-only $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} -- |\n \tfgrep -vx \".topdeps\" |\n \tfgrep -vx \".topmsg\" >\"$git_is_stupid\" || : # fgrep likes to fail randomly?\n@@ -61,7 +61,6 @@ if [ -s \"$git_is_stupid\" ]; then\n else\n \techo \"No changes.\"\n fi\n-rm \"$git_is_stupid\"\n \n echo '-- '\n echo \"tg: ($base_rev..) $name (depends on: $(cat_file \"$topic:.topdeps\" | paste -s -d' '))\"\ndiff --git a/tg-push.sh b/tg-push.sh\nindex 199d738..a928fba 100644 tg-push.sh\n--- a/tg-push.sh\n+++ b/tg-push.sh\n@@ -45,8 +45,7 @@ for name in $branches; do\n \tref_exists \"$name\" || die \"detached HEAD? Can't push $name\"\n done\n \n-_listfile=\"$(mktemp -t tg-push-listfile.XXXXXX)\"\n-trap \"rm -f \\\"$_listfile\\\"\" 0\n+_listfile=\"$(get_temp tg-push-listfile)\"\n \n push_branch()\n {\ndiff --git a/tg-summary.sh b/tg-summary.sh\nindex af16888..612bd27 100644 tg-summary.sh\n--- a/tg-summary.sh\n+++ b/tg-summary.sh\n@@ -55,10 +55,9 @@ EOT\n fi\n \n if [ -n \"$sort\" ]; then\n-\ttsort_input=`mktemp`\n+\ttsort_input=\"$(get_temp tg-summary-sort)\"\n \texec 4>$tsort_input\n \texec 5<$tsort_input\n-\trm $tsort_input\n fi\n \n ## List branches\ndiff --git a/tg-update.sh b/tg-update.sh\nindex b256c7c..5162c52 100644 tg-update.sh\n--- a/tg-update.sh\n+++ b/tg-update.sh\n@@ -27,7 +27,7 @@ base_rev=\"$(git rev-parse --short --verify \"refs/top-bases/$name\" 2>/dev/null)\"\n \n ## First, take care of our base\n \n-depcheck=\"$(mktemp -t tg-depcheck.XXXXXX)\"\n+depcheck=\"$(get_temp tg-depcheck)\"\n missing_deps=\n needs_update \"$name\" >\"$depcheck\" || :\n [ -z \"$missing_deps\" ] || die \"some dependencies are missing: $missing_deps\"\n@@ -96,7 +96,6 @@ if [ -s \"$depcheck\" ]; then\n else\n \tinfo \"The base is up-to-date.\"\n fi\n-rm \"$depcheck\"\n \n # Home, sweet home...\n # (We want to always switch back, in case we were on the base from failed\ndiff --git a/tg.sh b/tg.sh\nindex 8264a3b..3805eeb 100644 tg.sh\n--- a/tg.sh\n+++ b/tg.sh\n@@ -150,7 +150,7 @@ recurse_deps()\n \t_name=\"$1\"; # no shift\n \t_depchain=\"$*\"\n \n-\t_depsfile=\"$(mktemp -t tg-depsfile.XXXXXX)\"\n+\t_depsfile=\"$(get_temp tg-depsfile)\"\n \t# If no_remotes is unset check also our base against remote base.\n \t# Checking our head against remote head has to be done in the helper.\n \tif test -z \"$no_remotes\" && has_remote \"top-bases/$_name\"; then\n@@ -183,7 +183,6 @@ recurse_deps()\n \t\teval \"$_cmd\"\n \tdone <\"$_depsfile\"\n \tmissing_deps=\"${missing_deps# }\"\n-\trm \"$_depsfile\"\n \treturn $_ret\n }\n \n@@ -334,19 +333,28 @@ setup_pager()\n \t# now spawn pager\n \texport LESS=\"${LESS:-FRSX}\"\t# as in pager.c:pager_preexec()\n \n-\t_pager_fifo_dir=\"$(mktemp -t -d tg-pager-fifo.XXXXXX)\"\n-\t_pager_fifo=\"$_pager_fifo_dir/0\"\n-\tmkfifo -m 600 \"$_pager_fifo\"\n+\t# setup_pager should be called only once per command\n+\tpager_fifo=\"$tg_tmp_dir/pager\"\n+\tmkfifo -m 600 \"$pager_fifo\"\n \n-\t\"$TG_PAGER\" < \"$_pager_fifo\" &\n-\texec > \"$_pager_fifo\"\t\t# dup2(pager_fifo.in, 1)\n+\t\"$TG_PAGER\" < \"$pager_fifo\" &\n+\texec > \"$pager_fifo\"\t\t# dup2(pager_fifo.in, 1)\n \n \t# this is needed so e.g. `git diff` will still colorize it's output if\n \t# requested in ~/.gitconfig with color.diff=auto\n \texport GIT_PAGER_IN_USE=1\n \n \t# atexit(close(1); wait pager)\n-\ttrap \"exec >&-; rm \\\"$_pager_fifo\\\"; rmdir \\\"$_pager_fifo_dir\\\"; wait\" EXIT\n+\t# deliberately overwrites the global EXIT trap\n+\ttrap \"exec >&-; rm -rf \\\"$tg_tmp_dir\\\"; wait\" EXIT\n+}\n+\n+# get_temp NAME [-d]\n+# creates a new temporary file (or directory with -d) in the global\n+# temporary directory $tg_tmp_dir with pattern prefix NAME\n+get_temp()\n+{\n+\tmktemp ${2-} \"$tg_tmp_dir/$1.XXXXXX\"\n }\n \n ## Startup\n@@ -366,6 +374,9 @@ tg=\"tg\"\n # make sure merging the .top* files will always behave sanely\n setup_ours\n setup_hook \"pre-commit\"\n+# create global temporary directories, inside GIT_DIR\n+tg_tmp_dir=\"$(mktemp -d \"$git_dir/tg-tmp.XXXXXX\")\"\n+trap \"rm -rf \\\"$tg_tmp_dir\\\"\" EXIT\n \n ## Dispatch\n \n-- \n1.7.1.1067.g5aeb7\n"},{"id":"153101","messageId":"20101009215302.GR29673@pengutronix.de","threadId":"25406","inReplyTo":"d351f9124a96f212fe66ee85b4241753be94ab2b.1286660467.git.bert.wesarg@googlemail.com","subject":"Re: [TopGit PATCHv2] provide global temporary directory","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2010-10-09T21:53:02Z","receivedAt":"2010-10-09T21:53:02Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"On Sat, Oct 09, 2010 at 11:41:47PM +0200, Bert Wesarg wrote:\n> The standard procedure 'tmp=mktemp; trap \"rm $tmp\" 0' was broken with the\n> introduction of the pager. Which overwrites the trap itself to close and\n> remove the pager fifo.\n> \n> Now tg provides a temp playground and all other temp files should be created\n> inside this directory and only this directory will be removed with the exit\n> trap. setup_pager still overwrites the trap, but keeps the rm command from\n> the global temp directory. To simplify this the new function get_temp() is\n> provided.\n> \n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> ---\n>  hooks/pre-commit.sh |    3 +--\n>  tg-export.sh        |    3 +--\n>  tg-info.sh          |    3 +--\n>  tg-mail.sh          |    4 +---\n>  tg-patch.sh         |    3 +--\n>  tg-push.sh          |    3 +--\n>  tg-summary.sh       |    3 +--\n>  tg-update.sh        |    3 +--\n>  tg.sh               |   27 +++++++++++++++++++--------\n>  9 files changed, 27 insertions(+), 25 deletions(-)\n> \n> diff --git a/hooks/pre-commit.sh b/hooks/pre-commit.sh\n> index 4f2f16f..848a929 100644 hooks/pre-commit.sh\n> --- a/hooks/pre-commit.sh\n> +++ b/hooks/pre-commit.sh\n> @@ -95,9 +95,8 @@ BEGIN      { in_hunk = 0; }\n>  \tdone\n>  \n>  # check for repetitions of deps\n> -depdir=\"$(mktemp -t -d tg-depdir.XXXXXX)\" ||\n> +depdir=\"$(get_temp -d tg-depdir)\" ||\n>  \tdie \"Can't check for multiple occurrences of deps\"\n> -trap \"rm -rf '$depdir'\" 0\n>  cat_file \"(i):.topdeps\" |\n>  \twhile read dep; do\n>  \t\t[ ! -d \"$depdir/$dep\" ] ||\n> diff --git a/tg-export.sh b/tg-export.sh\n> index 6d82d55..921e933 100644 tg-export.sh\n> --- a/tg-export.sh\n> +++ b/tg-export.sh\n> @@ -57,8 +57,7 @@ if [ -z \"$branches\" ]; then\n>  fi\n>  \n>  \n> -playground=\"$(mktemp -d -t tg-export.XXXXXX)\"\n> -trap 'rm -rf \"$playground\"' EXIT\n> +playground=\"$(get_temp tg-export -d)\"\n>  \n>  \n>  ## Collapse driver\n> diff --git a/tg-info.sh b/tg-info.sh\n> index 7d6a34c..10e257e 100644 tg-info.sh\n> --- a/tg-info.sh\n> +++ b/tg-info.sh\n> @@ -51,7 +51,7 @@ fi\n>  git cat-file blob \"$name:.topdeps\" |\n>  \tsed '1{ s/^/Depends: /; n; }; s/^/         /;'\n>  \n> -depcheck=\"$(mktemp -t tg-depcheck.XXXXXX)\"\n> +depcheck=\"$(get_temp tg-depcheck)\"\n>  missing_deps=\n>  needs_update \"$name\" >\"$depcheck\" || :\n>  if [ -n \"$missing_deps\" ]; then\n> @@ -72,6 +72,5 @@ if [ -s \"$depcheck\" ]; then\n>  else\n>  \techo \"Up-to-date.\"\n>  fi\n> -rm \"$depcheck\"\n>  \n>  # vim:noet\n> diff --git a/tg-mail.sh b/tg-mail.sh\n> index 8167ade..dd4a95a 100644 tg-mail.sh\n> --- a/tg-mail.sh\n> +++ b/tg-mail.sh\n> @@ -34,7 +34,7 @@ if [ -n \"$in_reply_to\" ]; then\n>  fi\n>  \n>  \n> -patchfile=\"$(mktemp -t tg-mail.XXXXXX)\"\n> +patchfile=\"$(get_temp tg-mail)\"\n>  \n>  $tg patch \"$name\" >\"$patchfile\"\n>  \n> @@ -54,6 +54,4 @@ people=\n>  # NOTE: git-send-email handles cc itself\n>  eval git send-email $send_email_args \"$people\" \"$patchfile\"\n>  \n> -rm \"$patchfile\"\n> -\n>  # vim:noet\n> diff --git a/tg-patch.sh b/tg-patch.sh\n> index 7bafdfe..68efcf0 100644 tg-patch.sh\n> --- a/tg-patch.sh\n> +++ b/tg-patch.sh\n> @@ -51,7 +51,7 @@ echo\n>  [ -n \"$(git grep $diff_opts '^[-]--' ${diff_committed_only:+\"$name\"} -- \".topmsg\")\" ] || echo '---'\n>  \n>  # Evil obnoxious hack to work around the lack of git diff --exclude\n> -git_is_stupid=\"$(mktemp -t tg-patch-changes.XXXXXX)\"\n> +git_is_stupid=\"$(get_temp tg-patch-changes)\"\n>  git diff --name-only $diff_opts \"$base_rev\" ${diff_committed_only:+\"$name\"} -- |\n>  \tfgrep -vx \".topdeps\" |\n>  \tfgrep -vx \".topmsg\" >\"$git_is_stupid\" || : # fgrep likes to fail randomly?\n> @@ -61,7 +61,6 @@ if [ -s \"$git_is_stupid\" ]; then\n>  else\n>  \techo \"No changes.\"\n>  fi\n> -rm \"$git_is_stupid\"\n>  \n>  echo '-- '\n>  echo \"tg: ($base_rev..) $name (depends on: $(cat_file \"$topic:.topdeps\" | paste -s -d' '))\"\n> diff --git a/tg-push.sh b/tg-push.sh\n> index 199d738..a928fba 100644 tg-push.sh\n> --- a/tg-push.sh\n> +++ b/tg-push.sh\n> @@ -45,8 +45,7 @@ for name in $branches; do\n>  \tref_exists \"$name\" || die \"detached HEAD? Can't push $name\"\n>  done\n>  \n> -_listfile=\"$(mktemp -t tg-push-listfile.XXXXXX)\"\n> -trap \"rm -f \\\"$_listfile\\\"\" 0\n> +_listfile=\"$(get_temp tg-push-listfile)\"\n>  \n>  push_branch()\n>  {\n> diff --git a/tg-summary.sh b/tg-summary.sh\n> index af16888..612bd27 100644 tg-summary.sh\n> --- a/tg-summary.sh\n> +++ b/tg-summary.sh\n> @@ -55,10 +55,9 @@ EOT\n>  fi\n>  \n>  if [ -n \"$sort\" ]; then\n> -\ttsort_input=`mktemp`\n> +\ttsort_input=\"$(get_temp tg-summary-sort)\"\n>  \texec 4>$tsort_input\n>  \texec 5<$tsort_input\n> -\trm $tsort_input\n>  fi\n>  \n>  ## List branches\n> diff --git a/tg-update.sh b/tg-update.sh\n> index b256c7c..5162c52 100644 tg-update.sh\n> --- a/tg-update.sh\n> +++ b/tg-update.sh\n> @@ -27,7 +27,7 @@ base_rev=\"$(git rev-parse --short --verify \"refs/top-bases/$name\" 2>/dev/null)\"\n>  \n>  ## First, take care of our base\n>  \n> -depcheck=\"$(mktemp -t tg-depcheck.XXXXXX)\"\n> +depcheck=\"$(get_temp tg-depcheck)\"\n>  missing_deps=\n>  needs_update \"$name\" >\"$depcheck\" || :\n>  [ -z \"$missing_deps\" ] || die \"some dependencies are missing: $missing_deps\"\n> @@ -96,7 +96,6 @@ if [ -s \"$depcheck\" ]; then\n>  else\n>  \tinfo \"The base is up-to-date.\"\n>  fi\n> -rm \"$depcheck\"\n>  \n>  # Home, sweet home...\n>  # (We want to always switch back, in case we were on the base from failed\n> diff --git a/tg.sh b/tg.sh\n> index 8264a3b..3805eeb 100644 tg.sh\n> --- a/tg.sh\n> +++ b/tg.sh\n> @@ -150,7 +150,7 @@ recurse_deps()\n>  \t_name=\"$1\"; # no shift\n>  \t_depchain=\"$*\"\n>  \n> -\t_depsfile=\"$(mktemp -t tg-depsfile.XXXXXX)\"\n> +\t_depsfile=\"$(get_temp tg-depsfile)\"\n>  \t# If no_remotes is unset check also our base against remote base.\n>  \t# Checking our head against remote head has to be done in the helper.\n>  \tif test -z \"$no_remotes\" && has_remote \"top-bases/$_name\"; then\n> @@ -183,7 +183,6 @@ recurse_deps()\n>  \t\teval \"$_cmd\"\n>  \tdone <\"$_depsfile\"\n>  \tmissing_deps=\"${missing_deps# }\"\n> -\trm \"$_depsfile\"\n>  \treturn $_ret\n>  }\n>  \n> @@ -334,19 +333,28 @@ setup_pager()\n>  \t# now spawn pager\n>  \texport LESS=\"${LESS:-FRSX}\"\t# as in pager.c:pager_preexec()\n>  \n> -\t_pager_fifo_dir=\"$(mktemp -t -d tg-pager-fifo.XXXXXX)\"\n> -\t_pager_fifo=\"$_pager_fifo_dir/0\"\n> -\tmkfifo -m 600 \"$_pager_fifo\"\n> +\t# setup_pager should be called only once per command\n> +\tpager_fifo=\"$tg_tmp_dir/pager\"\n> +\tmkfifo -m 600 \"$pager_fifo\"\n>  \n> -\t\"$TG_PAGER\" < \"$_pager_fifo\" &\n> -\texec > \"$_pager_fifo\"\t\t# dup2(pager_fifo.in, 1)\n> +\t\"$TG_PAGER\" < \"$pager_fifo\" &\n> +\texec > \"$pager_fifo\"\t\t# dup2(pager_fifo.in, 1)\n>  \n>  \t# this is needed so e.g. `git diff` will still colorize it's output if\n>  \t# requested in ~/.gitconfig with color.diff=auto\n>  \texport GIT_PAGER_IN_USE=1\n>  \n>  \t# atexit(close(1); wait pager)\n> -\ttrap \"exec >&-; rm \\\"$_pager_fifo\\\"; rmdir \\\"$_pager_fifo_dir\\\"; wait\" EXIT\n> +\t# deliberately overwrites the global EXIT trap\n> +\ttrap \"exec >&-; rm -rf \\\"$tg_tmp_dir\\\"; wait\" EXIT\n> +}\n> +\n> +# get_temp NAME [-d]\nI like your patch in general, but would prefer to have\n\n\t# get_temp [-d] NAME\n\n> +# creates a new temporary file (or directory with -d) in the global\n> +# temporary directory $tg_tmp_dir with pattern prefix NAME\n> +get_temp()\n> +{\n> +\tmktemp ${2-} \"$tg_tmp_dir/$1.XXXXXX\"\nDoes the - makes any difference?  If yes, is it portable (enough)?\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"},{"id":"153120","messageId":"AANLkTikuEa6TQpEnv=0y3v18W9H8sC4SQ+5vdTvBW7LF@mail.gmail.com","threadId":"25406","inReplyTo":"20101009215302.GR29673@pengutronix.de","subject":"Re: [TopGit PATCHv2] provide global temporary directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-10-10T07:47:47Z","receivedAt":"2010-10-10T07:47:47Z","isPatch":false,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"2010/10/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:\n> On Sat, Oct 09, 2010 at 11:41:47PM +0200, Bert Wesarg wrote:\n>> +# get_temp NAME [-d]\n> I like your patch in general, but would prefer to have\n>\n>        # get_temp [-d] NAME\n\nBut that would complicate the argument evaluation, wouldn't it:\n\nget_temp()\n{\n    if [ $# -eq 2 ]; then\n        mktemp $1 \"$tg_tmp_dir/$2.XXXXXX\"\n    else\n        mktemp \"$tg_tmp_dir/$1.XXXXXX\"\n    fi\n}\n\nThis and the functions with [-i | -w] are internal and won't be called\nby the user, so we have full control over the calling convention and\nshould make it easy for us. And putting the optional argument at the\nend is easy. I should probably remove the die call in cat_file,\nbecause that would be an programmer error not an user error.\n\n>\n>> +# creates a new temporary file (or directory with -d) in the global\n>> +# temporary directory $tg_tmp_dir with pattern prefix NAME\n>> +get_temp()\n>> +{\n>> +     mktemp ${2-} \"$tg_tmp_dir/$1.XXXXXX\"\n> Does the - makes any difference?  If yes, is it portable (enough)?\n\nFor me its an indicator, that it doesn't matter whether $2 was given\nor not. Also you could run under set -u without error. But I don't do\nthis.\n\nIt's in POSIX [1].\n\nBert\n\n[1] Statement given without interpretation.\n\n> Best regards\n> Uwe\n>\n> --\n> Pengutronix e.K.                           | Uwe Kleine-König            |\n> Industrial Linux Solutions                 | http://www.pengutronix.de/  |\n>\n"}]}