68425c266a5107e50a2897b7d7cfc0ccb9fb753c

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

extract: replace basename&sed w/ zsh variable expansion syntax

`${var:t:h}` uses:

- `${var:t}` which acts as `basename`.

- `${var:r}` which removes the extension.

See http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers

Diff

 1diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
 2index 24b16517b9a43f427497c989b290e1311895ec4f..c524bf8f56142edc289fc9c3f0af2e8ab9947e36 100644
 3--- a/plugins/extract/extract.plugin.zsh
 4+++ b/plugins/extract/extract.plugin.zsh
 5@@ -3,7 +3,6 @@ alias x=extract
 6 extract() {
 7 	local remove_archive
 8 	local success
 9-	local file_name
10 	local extract_dir
11 
12 	if (( $# == 0 )); then
13@@ -29,8 +28,7 @@ extract() {
14 		fi
15 
16 		success=0
17-		file_name="$( basename "$1" )"
18-		extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
19+		extract_dir="${1:t:r}"
20 		case "$1" in
21 			(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
22 			(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;