bugQuilt - Bugs: bug #21309, patchfns.in: gen_tempfile() -- Fix...

 
 

bug #21309: patchfns.in: gen_tempfile() -- Fix path generation under Cygwin

Submitter:  Jari Aalto <jaalto>
Submitted:  Wed 10 Oct 2007 07:11:50 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 17 Jun 2009 11:44:54 AM UTC, comment #1: 

Is this okay as well? (I'm committing this assuming that it is.)

--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -841,12 +841,11 @@ in_array()

 gen_tempfile()
 {
-       local name
        if [ "$1" = -d ]
        then
-               mktemp -d ${2:-${TMPDIR:-/tmp}/${0// /_}}.XXXXXX
+               mktemp -d ${2:-${TMPDIR:-/tmp}}/quilt.XXXXXX
        else
-               mktemp ${1:-${TMPDIR:-/tmp}/${0// /_}}.XXXXXX
+               mktemp ${1:-${TMPDIR:-/tmp}}/quilt.XXXXXX
        fi
 }

Andreas Gruenbacher <agruen>
Group administrator
Wed 10 Oct 2007 07:11:50 AM UTC, original submission:  

PROBLEM
-------

The code in gen_tempfile() does not consider that $0 may contain
absolute path component.

The following patch fixes it.

ERROR MESSAGE UNDER CYGWIN
---------------------------

 QUILT_DIR=/usr/share/quilt QUILT_LIB=/usr/lib/quilt bash -x /usr/share/quilt/annotate test


/usr/share/quilt/annotate
    146
    147 template=$(gen_tempfile)
    148
    149 trap "rm -f $template" EXIT

++ mktemp /tmp//usr/share/quilt/annotate.XXXXXX
mktemp: cannot create temp file /tmp//usr/share/quilt/annotate.mS2300: No such file or directory

PATCH
------

 quilt/scripts/patchfns.in |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index f6407b4..9d77dd2 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -841,12 +841,19 @@ in_array()
 
 gen_tempfile()
 {
-       local name
+       local name=${0// /_}
+        name=${name##*/}    # Remove path components
+
+        local dir
+
        if [ "$1" = -d ]
        then
-               mktemp -d ${2:-${TMPDIR:-/tmp}/${0// /_}}.XXXXXX
+                dir=${2:-${TMPDIR:-/tmp}}
+               mktemp -d $dir/$name.XXXXXX
        else
-               mktemp ${1:-${TMPDIR:-/tmp}/${0// /_}}.XXXXXX
+                dir=${1:-${TMPDIR:-/tmp}}
+               mktemp -d $dir/$name.XXXXXX
+
        fi
 }




Jari Aalto <jaalto>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by agruen (Posted a comment)
  • -email is unavailable- added by jaalto (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-06-17 agruen StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code