Merge pull request #1926 from gaelicWizard/basenamed

Use parameter substitution instead of `dirname`/`basename`, where safe to do so
This commit is contained in:
Noah Gorny
2021-09-18 18:26:55 +03:00
committed by GitHub
7 changed files with 24 additions and 22 deletions

View File

@@ -16,7 +16,7 @@ editpost() {
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
if [ "${site##*/}" = "$1" ]
then
SITE=$site
break
@@ -77,7 +77,7 @@ newpost() {
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
if [ "${site##*/}" = "$1" ]
then
SITE=$site
JEKYLL_FORMATTING=${MARKUPS[$loc]}
@@ -280,7 +280,7 @@ function testsite() {
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
if [ "${site##*/}" = "$1" ]
then
SITE=$site
break
@@ -312,7 +312,7 @@ function buildsite() {
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
if [ "${site##*/}" = "$1" ]
then
SITE=$site
break
@@ -347,7 +347,7 @@ function deploysite() {
for site in ${SITES[@]}
do
if [ "$(basename $site)" = "$1" ]
if [ "${site##*/}" = "$1" ]
then
SITE=$site
REMOTE=${REMOTES[$loc]}

View File

@@ -15,7 +15,7 @@ function time-machine-list-machines() {
local tmdest="$(time-machine-destination)/Backups.backupdb"
find "$tmdest" -maxdepth 1 -mindepth 1 -type d | grep -v "/\." | while read line ; do
echo "$(basename "$line")"
echo "${line##*/}"
done
}

View File

@@ -14,8 +14,8 @@ function mkvenv {
about 'create a new virtualenv for this directory'
group 'virtualenv'
cwd=`basename \`pwd\``
mkvirtualenv --distribute $cwd
local cwd="${PWD##*/}"
mkvirtualenv --distribute "$cwd"
}
@@ -23,19 +23,21 @@ function mkvbranch {
about 'create a new virtualenv for the current branch'
group 'virtualenv'
mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH"
local cwd="${PWD##*/}"
mkvirtualenv --distribute "${cwd}@${SCM_BRANCH}"
}
function wovbranch {
about 'sets workon branch'
group 'virtualenv'
workon "$(basename `pwd`)@$SCM_BRANCH"
local cwd="${PWD##*/}"
workon "${cwd}@${SCM_BRANCH}"
}
function wovenv {
about 'works on the virtualenv for this directory'
group 'virtualenv'
workon "$(basename `pwd`)"
workon "${PWD##*/}"
}

View File

@@ -11,7 +11,7 @@ autoenv_init()
typeset target home _file
typeset -a _files
target=$1
home="$(dirname "$HOME")"
home="${HOME%/*}"
_files=( $(
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]