diff options
author | Jim Meyering <jim@meyering.net> | 1995-05-05 04:16:12 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1995-05-05 04:16:12 +0000 |
commit | f45ff2cfafdff83ac03c390fc131fd3e4364cdca (patch) | |
tree | 178e09813c5cd099534aba4f27be41255417d676 /src | |
parent | 6cd5abb0c4ced77cd8f413d51c78a539dcfad5a3 (diff) | |
download | coreutils-f45ff2cfafdff83ac03c390fc131fd3e4364cdca.tar.xz |
Don't hard-code /tmp.
[DEFAULT_TMPDIR]: Use this instead.
Diffstat (limited to 'src')
-rw-r--r-- | src/sort.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/sort.c b/src/sort.c index d45b66499..e359bbbc9 100644 --- a/src/sort.c +++ b/src/sort.c @@ -52,6 +52,10 @@ static void usage (); #define UCHAR_LIM (UCHAR_MAX + 1) #define UCHAR(c) ((unsigned char) (c)) +#ifndef DEFAULT_TMPDIR +#define DEFAULT_TMPDIR "/tmp" +#endif + /* The kind of blanks for '-b' to skip in various options. */ enum blanktype { bl_start, bl_end, bl_both }; @@ -312,10 +316,10 @@ tempname () (struct tempnode *) xmalloc (sizeof (struct tempnode)); sprintf (name, - (len && temp_file_prefix[len - 1] != '/' - ? "%s/sort%5.5d%5.5d" - : "%ssort%5.5d%5.5d"), - temp_file_prefix, (unsigned int) getpid () & 0xffff, ++seq); + "%s%ssort%5.5d%5.5d", + temp_file_prefix, + (len && temp_file_prefix[len - 1] != '/') ? "/" : "", + (unsigned int) getpid () & 0xffff, ++seq); node->name = name; node->next = temphead.next; temphead.next = node; @@ -1477,7 +1481,7 @@ main (argc, argv) temp_file_prefix = getenv ("TMPDIR"); if (temp_file_prefix == NULL) - temp_file_prefix = "/tmp"; + temp_file_prefix = DEFAULT_TMPDIR; #ifdef _POSIX_VERSION newact.sa_handler = sighandler; @@ -1841,7 +1845,7 @@ Usage: %s [OPTION]... [FILE]...\n\ \n\ +POS1 [-POS2] start a key at POS1, end it before POS2\n\ -M compare (unknown) < `JAN' < ... < `DEC', imply -b\n\ - -T DIRECT use DIRECT for temporary files, not $TMPDIR or /tmp\n\ + -T DIRECT use DIRECT for temporary files, not $TMPDIR or %s\n\ -b ignore leading blanks in sort fields or keys\n\ -c check if given files already sorted, do not sort\n\ -d consider only [a-zA-Z0-9 ] characters in keys\n\ @@ -1864,7 +1868,8 @@ position in the field, both counted from zero. OPTS is made up of one\n\ or more of Mbdfinr, this effectively disable global -Mbdfinr settings\n\ for that key. If no key given, use the entire line as key. With no\n\ FILE, or when FILE is -, read standard input.\n\ -"); +" + , DEFAULT_TMPDIR); } exit (status); } |