Ticket #10192: trac_10192-remove_dot_and_more_from_PYTHONPATH_in_sage.spkg.patch

File trac_10192-remove_dot_and_more_from_PYTHONPATH_in_sage.spkg.patch, 1.2 KB (added by ppurka, 10 years ago)

New attempt to clean up even nastier paths (including .., ./., etc) (Ignore the other patch)

  • sage-spkg

    # HG changeset patch
    # User P Purkayastha <ppurka@gmail.com>
    # Date 1318509965 -28800
    # Node ID 23eeb01f70213a837c05c77c46ed7d3e42718532
    # Parent  0cc3111a620d1dbe9072f3f0efa2bdef9d6c79bc
    # trac 10192: Remove ., .., ./ and any such combination from PYTHONPATH
    
    diff --git a/sage-spkg b/sage-spkg
    a b  
    300300
    301301chmod +x spkg-install
    302302
     303# Remove '.' './.' '..' '' and any combination of these from PYTHONPATH
     304# See trac #10192, #10176
     305if [ -n "$PYTHONPATH" ]; then
     306    new_pp=""
     307    old_ifs="$IFS"
     308    IFS=":"
     309    for x in $PYTHONPATH; do
     310        if [ -n "$x" -a -n "$(echo "$x" | sed -e 's/[\.\/]\+//g')" ]; then
     311            if [ -z "$new_pp" ]; then
     312                new_pp="$x"
     313            else
     314                new_pp="${new_pp}:$x"
     315            fi
     316        fi
     317    done
     318    IFS="$old_ifs"
     319    if [ "$PYTHONPATH" != "$new_pp" ]; then
     320        echo "Cleaning up PYTHONPATH:"
     321        echo "  Old: \"$PYTHONPATH\""
     322        echo "  New: \"$new_pp\""
     323        PYTHONPATH="$new_pp"
     324        export PYTHONPATH
     325    fi
     326fi
     327
    303328# this is just wrong... (so don't do it)
    304329#echo "TOUCHING"
    305330#touch * */* */*/* */*/*/* 1>/dev/null 2>/dev/null