Skip to content

Commit

Permalink
Replaced bash regex usage in 'trash' (which requires bash 3.0+, first…
Browse files Browse the repository at this point in the history
… included in Mac OS X 10.5 Leopard) with a call to read w/IFS. Added v0.2.1 release notes & fixed date for v0.2 release. (Issue #158)
  • Loading branch information
morgant committed Oct 26, 2010
1 parent 02d03e7 commit ae055f6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions trash
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
#
# v0.1 2007-05-21 - Morgan Aldridge <[email protected]>
# Initial version.
# v0.2 2010-10-25 - Morgan Aldridge
# v0.2 2010-10-26 - Morgan Aldridge
# Use appropriate .Trashes folder when trashing files
# on other volumes. Create trash folder(s) if necessary.
# v0.2.1 2010-10-26 - Morgan Aldridge
# No longer using bash built-in regexp support in hopes
# of support Mac OS X 10.4 and earlier.
#

# TO DO:
Expand Down Expand Up @@ -52,10 +55,8 @@ if [ $# -gt 0 ]; then
if $verbose; then v="-v"; fi
# determine whether we should be putting this in a volume-specific .Trashes or user's .Trash
if [ "${1:0:9}" = "/Volumes/" -o "${1:0:9}" = "/Volumes/" ]; then
if [[ "$1" =~ ^/Volumes/([^/]+) ]]; then
vol="${BASH_REMATCH[1]}"
trash="/Volumes/${vol}/.Trashes/${uid}/"
fi
IFS=/ read -r -d '' _ _ vol _ <<< "$1"
trash="/Volumes/${vol}/.Trashes/${uid}/"
else
trash="/Users/${user}/.Trash/"
fi
Expand Down

0 comments on commit ae055f6

Please sign in to comment.