Temp file patches
- From: Leonard den Ottolander <leonard den ottolander nl>
- To: mc-devel gnome org
- Subject: Temp file patches
- Date: Wed, 07 Jul 2004 15:09:08 +0200
Hi,
Let's see if sending a patch to the list now succeeds.
The temp file patch I sent to Pavel before contains two hunks that don't
patch against CVS, because a different code page is now used (or are
they converted during the rpm build?). Also added are similar temp file
fixes for doc/pl/mc.1.in and doc/sr/mc.1.in, which I mentioned before.
Please note any omissions you find.
This brings up the question of the code pages used for docs. Would it be
a good idea to code all docs in UTF-8?
Leonard.
--
mount -t life -o ro /dev/dna /genetic/research
diff -pru mc.000/doc/es/mc.1.in mc/doc/es/mc.1.in
--- mc.000/doc/es/mc.1.in 2003-12-30 18:43:56.000000000 +0100
+++ mc/doc/es/mc.1.in 2004-07-07 14:53:26.000000000 +0200
@@ -1375,8 +1375,10 @@ A Vuelca el contenido del archivo selecc
od -c %f
B Edita un informe de errores y lo envía al superusuario
- vi /tmp/mail.$$
- mail -s "Error Midnight Commander" root < /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "Error Midnight Commander" root < $I
+ rm -f $I
M Lee al correo
emacs -f rmail
diff -pru mc.000/doc/hu/mc.1.in mc/doc/hu/mc.1.in
--- mc.000/doc/hu/mc.1.in 2003-06-18 06:24:27.000000000 +0200
+++ mc/doc/hu/mc.1.in 2004-07-07 14:54:47.000000000 +0200
@@ -1381,8 +1381,10 @@ A A kiválasztott fájlok listázása
od -c %f
B A hiba leírás szerkesztése és elküldése a root-nak
- vi /tmp/mail.$$
- mail -s "Midnight Commander bug" root < /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "Midnight Commander bug" root < $I
+ rm -f $I
M Levél olvasás
emacs -f rmail
diff -pru mc.000/doc/it/mc.1.in mc/doc/it/mc.1.in
--- mc.000/doc/it/mc.1.in 2003-06-25 18:01:50.000000000 +0200
+++ mc/doc/it/mc.1.in 2004-07-07 14:49:44.000000000 +0200
@@ -1390,8 +1390,10 @@ A Mostra un dump del file correntemente
od -c %f
B Modifica un rapporto bachi e lo spedisce a root
- vi /tmp/mail.$$
- mail -s "Midnight Commander bug" root < /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "Midnight Commander bug" root < $I
+ rm -f $I
M Legge la posta
emacs -f rmail
diff -pru mc.000/doc/mc.1.in mc/doc/mc.1.in
--- mc.000/doc/mc.1.in 2003-11-14 22:13:00.000000000 +0100
+++ mc/doc/mc.1.in 2004-07-07 14:49:43.000000000 +0200
@@ -1395,8 +1395,10 @@ A Dump the currently selected file
od -c %f
B Edit a bug report and send it to root
- vi /tmp/mail.$$
- mail -s "Midnight Commander bug" root < /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "Midnight Commander bug" root < $I
+ rm -f $I
M Read mail
emacs -f rmail
diff -pru mc.000/doc/pl/mc.1.in mc/doc/pl/mc.1.in
--- mc.000/doc/pl/mc.1.in 2003-06-18 06:24:29.000000000 +0200
+++ mc/doc/pl/mc.1.in 2004-07-07 14:56:38.000000000 +0200
@@ -1174,8 +1174,10 @@ A Wyrzuæ aktualny plik.
od -c %f
B Stwórz raport o b³êdzie i wy¶lij do roota.
- vi ~/tmp/mail.$$
- mail -s "B³±d Midnight Commandera" root < ~/tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "B³±d Midnight Commandera" root < $I
+ rm -f $I
M Przeczytaj pocztê.
emacs -f rmail
diff -pru mc.000/doc/ru/mc.1.in mc/doc/ru/mc.1.in
--- mc.000/doc/ru/mc.1.in 2004-03-07 06:58:48.000000000 +0100
+++ mc/doc/ru/mc.1.in 2004-07-07 14:49:43.000000000 +0200
@@ -1560,8 +1560,10 @@ A Dump the currently selected file
od -c %f
B Edit a bug report and send it to root
- vi /tmp/mail.$$
- mail -s "Midnight Commander bug" root < /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "Midnight Commander bug" root < $I
+ rm -f $I
M Read mail
emacs -f rmail
diff -pru mc.000/doc/sr/mc.1.in mc/doc/sr/mc.1.in
--- mc.000/doc/sr/mc.1.in 2003-10-10 23:01:25.000000000 +0200
+++ mc/doc/sr/mc.1.in 2004-07-07 14:57:50.000000000 +0200
@@ -1383,8 +1383,10 @@ A žáâàÕáÐ áÐÔàÖÐø âàÕÝãâÝÞ Ø×ÐÑàÐÝÕ ÔÐâÞ
od -c %f
B ÃàÕòãøÕ ßàØøÐÒã ÓàÕèÚÕ Ø èÐùÕ øÕ ÐÔÜØÝØáâàÐâÞàã
- vi /tmp/mail.$$
- mail -s "³àÕèÚÐ ã ßÞÝÞûÝÞÜ ÝÐàÕÔÝØÚã" root < /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ vi $I
+ mail -s "³àÕèÚÐ ã ßÞÝÞûÝÞÜ ÝÐàÕÔÝØÚã" root < $I
+ rm -f $I
M ÇØâÐ ßÞèâã
emacs -f rmail
diff -pru mc.000/lib/cedit.menu mc/lib/cedit.menu
--- mc.000/lib/cedit.menu 2003-08-03 01:01:51.000000000 +0200
+++ mc/lib/cedit.menu 2004-07-07 14:49:44.000000000 +0200
@@ -454,7 +454,7 @@ s Invoke `shell'
m view `man'
MAN=%{Enter name of man:}
- TMPFILE=/tmp/mcview.$MAN.$$
+ TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/mcview.$MAN.$$` || exit 1
man -Pcat $MAN >$TMPFILE
mcview $TMPFILE
rm -f $TMPFILE
diff -pru mc.000/lib/mc.menu mc/lib/mc.menu
--- mc.000/lib/mc.menu 2003-09-10 02:17:25.000000000 +0200
+++ mc/lib/mc.menu 2004-07-07 14:49:44.000000000 +0200
@@ -14,9 +14,10 @@ shell_patterns=0
0 Edit a bug report and send it to root
- ${EDITOR-vi} /tmp/mail.$$
- test -r /tmp/mail.$$ && mail root < /tmp/mail.$$
- rm -f /tmp/mail.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1
+ ${EDITOR-vi} $I
+ test -r $I && mail root < $I
+ rm -f $I
=+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r
1 Display the file with roff -man
@@ -116,8 +117,9 @@ h Strip headers from current newsa
CHECK=`awk '{print $1 ; exit}' %f` 2>/dev/null
case $CHECK in
Newsgroups:|Path:)
- cp %f /tmp/%f.$$ && sed '/^'"$CHECK"' /,/^$/d' /tmp/%f.$$ > %f
- [ "$?" = "0" ] && rm /tmp/%f.$$
+ I=`mktemp ${MC_TMPDIR:-/tmp}/news.XXXXXX` || exit 1
+ cp %f $I && sed '/^'"$CHECK"' /,/^$/d' $I > %f
+ [ "$?" = "0" ] && rm $I
echo %f: header removed
;;
*)
@@ -130,7 +132,7 @@ H Strip headers from the marked ne
set %t
while [ -n "$1" ]; do
CHECK=`awk '{print $1 ; exit}' $1` 2>/dev/null
- WFILE=/tmp/${1}.$$
+ WFILE=`mktemp ${MC_TMPDIR:-/tmp}/news.XXXXXX` || exit 1
case $CHECK in
Newsgroups:|Path:)
cp $1 $WFILE && sed '/^'"$CHECK"' /,/^$/d' $WFILE > $1
diff -pru mc.000/vfs/extfs/deb.in mc/vfs/extfs/deb.in
--- mc.000/vfs/extfs/deb.in 2002-12-11 21:57:00.000000000 +0100
+++ mc/vfs/extfs/deb.in 2004-07-07 14:49:44.000000000 +0200
@@ -149,15 +149,10 @@ sub mcdebfs_run
}
else
{
- $suffix = "aaa";
- while (1) {
- $tmpdir = "/tmp/mcdebfs.run".$$.$suffix;
- last if mkdir $tmpdir, 0700;
- $suffix++;
- # Somebody is being really nasty, give up
- exit 1 if $suffix eq "zzz";
- }
-
+ use File::Temp qw(mkdtemp);
+ my $template = "/tmp/mcdebfs.run.XXXXXX";
+ $template="$ENV{MC_TMPDIR}/mcdebfs.XXXXXX" if ($ENV{MC_TMPDIR});
+ $tmpdir = mkdtemp($template);
$tmpcmd="$tmpdir/run";
&mcdebfs_copyout($archive, $filename, $tmpcmd);
system("chmod u+x $tmpcmd");
diff -pru mc.000/vfs/extfs/uar.in mc/vfs/extfs/uar.in
--- mc.000/vfs/extfs/uar.in 2002-12-12 10:21:35.000000000 +0100
+++ mc/vfs/extfs/uar.in 2004-07-07 14:49:44.000000000 +0200
@@ -22,8 +22,7 @@ mcarfs_copyout ()
mcarfs_copyin ()
{
- TMPDIR=/tmp/mctmpdir-uar.$$
- mkdir $TMPDIR || exit 1
+ TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uar.XXXXXX` || exit 1
name=`basename "$2"`
(cd $TMPDIR && cp -fp "$3" $name && $XAR r "$1" $name)
rm -rf $TMPDIR
diff -pru mc.000/vfs/extfs/uha.in mc/vfs/extfs/uha.in
--- mc.000/vfs/extfs/uha.in 2002-12-14 06:10:53.000000000 +0100
+++ mc/vfs/extfs/uha.in 2004-07-07 14:49:44.000000000 +0200
@@ -31,8 +31,7 @@ mchafs_list ()
mchafs_copyout ()
{
- TMPDIR="/tmp/mctmpdir-uha.$$"
- mkdir $TMPDIR || exit 1
+ TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uha.XXXXXX` || exit 1
cd $TMPDIR
$HA xyq "$1" "$2" >/dev/null
diff -pru mc.000/vfs/extfs/ulha.in mc/vfs/extfs/ulha.in
--- mc.000/vfs/extfs/ulha.in 2002-12-14 05:39:10.000000000 +0100
+++ mc/vfs/extfs/ulha.in 2004-07-07 14:49:44.000000000 +0200
@@ -35,12 +35,6 @@ LHA_LIST="lha lq"
LHA_GET="lha pq"
LHA_PUT="lha aq"
-# Define a directory to create a temporary file for when
-# running a command to be run from the archive
-TMPDIR="/tmp/mctmpdir-uha.$$"
-# Temporary file within the directory
-TMPCMD=$TMPDIR/run
-
# The 'list' command executive
mc_lha_fs_list()
@@ -121,9 +115,9 @@ mc_lha_fs_copyin ()
mc_lha_fs_run()
{
+ TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-ulha.XXXXXX` || exit 1
trap "rm -rf $TMPDIR; exit 0" 1 2 3 4 15
- # FIXME: Try harder to generate a unique directory if this fails
- mkdir -m 0700 $TMPDIR || exit 1
+ TMPCMD=$TMPDIR/run
$LHA_GET "$1" "$2" > $TMPCMD
chmod a+x $TMPCMD
$TMPCMD
diff -pru mc.000/vfs/extfs/urar.in mc/vfs/extfs/urar.in
--- mc.000/vfs/extfs/urar.in 2003-01-24 08:10:05.000000000 +0100
+++ mc/vfs/extfs/urar.in 2004-07-07 14:49:44.000000000 +0200
@@ -77,8 +77,7 @@ mcrarfs_mkdir ()
# preserve pwd. It is clean, but is it necessary?
pwd=`pwd`
# Create a directory and create in it a tmp directory with the good name
- dir=tmpdir.${RANDOM}
- mkdir $dir
+ dir=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-urar.XXXXXX` || exit 1
cd $dir
mkdir -p "$2"
# rar cannot create an empty directory
diff -pru mc.000/vfs/extfs/uzip.in mc/vfs/extfs/uzip.in
--- mc.000/vfs/extfs/uzip.in 2003-08-18 07:17:25.000000000 +0200
+++ mc/vfs/extfs/uzip.in 2004-07-07 14:49:44.000000000 +0200
@@ -344,10 +344,10 @@ sub cleandirs {
# Make a temporary directory with mode 0700.
sub mktmpdir {
- while (1) {
- my $dir = POSIX::tmpnam();
- return $dir if mkdir ($dir, 0700);
- }
+ use File::Temp qw(mkdtemp);
+ my $template = "/tmp/mcuzipfs.XXXXXX";
+ $template="$ENV{MC_TMPDIR}/mcuzipfs.XXXXXX" if ($ENV{MC_TMPDIR});
+ return mkdtemp($template);
}
# Make a filename absolute and return it.
diff -pru mc.000/vfs/extfs/uzoo.in mc/vfs/extfs/uzoo.in
--- mc.000/vfs/extfs/uzoo.in 2002-12-14 05:29:13.000000000 +0100
+++ mc/vfs/extfs/uzoo.in 2004-07-07 14:49:44.000000000 +0200
@@ -13,8 +13,7 @@ ZOO=zoo
# it to a temporary directory.
mklink ()
{
- TMPDIR="/tmp/mctmpdir-uzoo.$$"
- mkdir $TMPDIR || exit 1
+ TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uzoo.XXXXXX` || exit 1
trap 'cd /; rm -rf $TMPDIR' 0 1 2 3 5 13 15
ARCHIVE=$TMPDIR/tmp.zoo
ln -sf "$1" "$ARCHIVE"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]