Skip to content

Commit 22ffac3

Browse files
author
Ira Abramov
committed
a few more shellcheck fixes and I think we are done.
1 parent 44ce481 commit 22ffac3

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

themes/metal/metal.theme.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ function virtualenv_prompt {
6262

6363
# Rename tab
6464
function tabname {
65+
# shellcheck disable=SC2059
6566
printf "\e]1;$1\a"
6667
}
6768

6869
# Rename window
6970
function winname {
71+
# shellcheck disable=SC2059
7072
printf "\e]2;$1\a"
7173
}
7274

themes/modern-time/modern-time.theme.bash

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SCM_GIT_CHAR="${bold_green?}±${normal?}"
1313
SCM_SVN_CHAR="${bold_cyan?}${normal?}"
1414
SCM_HG_CHAR="${bold_red?}${normal?}"
1515

16-
case $TERM in
16+
case ${TERM} in
1717
xterm*)
1818
TITLEBAR="\[\033]0;\w\007\]"
1919
;;
@@ -36,6 +36,7 @@ modern_current_time_prompt() {
3636

3737
prompt() {
3838
SCM_PROMPT_FORMAT='[%s][%s]'
39+
# shellcheck disable=SC2181
3940
if [ $? -ne 0 ]; then
4041
# Yes, the indenting on these is weird, but it has to be like
4142
# this otherwise it won't display properly.

themes/parrot/parrot.theme.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function prompt() {
2828
fi
2929

3030
if [ "$color_prompt" = yes ]; then
31+
# shellcheck disable=SC2028
3132
PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]$(parse_git_branch) $\[\e[0m\] "
3233

3334
else

themes/powerline-plain/powerline-plain.base.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
function __powerline_left_segment {
77
local OLD_IFS="${IFS}"
88
IFS="|"
9+
# shellcheck disable=SC2206
910
local params=($1)
1011
IFS="${OLD_IFS}"
1112
local pad_before_segment=" "

themes/powerturk/powerturk.theme.bash

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ LAST_STATUS_THEME_PROMPT_COLOR=52
3232

3333
_collapsed_wd() {
3434
# echo -e "\u2771\u276d\u276f"
35-
echo $(pwd | perl -pe "
35+
# shellcheck disable=SC2005
36+
echo "$(pwd | perl -pe "
3637
BEGIN {
3738
binmode STDIN, ':encoding(UTF-8)';
3839
binmode STDOUT, ':encoding(UTF-8)';
39-
}; s|^$HOME|<HOME>|g; s|/([^/])[^/]*(?=/)|/\$1|g") \
40+
}; s|^$HOME|<HOME>|g; s|/([^/])[^/]*(?=/)|/\$1|g")" \
4041
| sed -re "s/\//  /g"
4142
}
4243

@@ -47,22 +48,22 @@ _swd() {
4748
current="" # The section of the path we're currently working on.
4849
end="${2:-${PWD}}/" # The unmodified rest of the path.
4950

50-
if [[ "$end" =~ "$HOME" ]]; then
51+
if [[ "$end" =~ $HOME ]]; then
5152
INHOME=1
52-
end="${end#$HOME}" #strip /home/username from start of string
53-
begin="$HOME" #start expansion from the right spot
53+
end="${end#"$HOME"}" #strip /home/username from start of string
54+
begin="${HOME}" #start expansion from the right spot
5455
else
5556
INHOME=0
5657
fi
5758

58-
end="${end#/}" # Strip the first /
59-
shortenedpath="$end" # The whole path, to check the length.
59+
end="${end#/}" # Strip the first /
60+
shortenedpath="${end}" # The whole path, to check the length.
6061
maxlength="${1:-0}"
6162

6263
shopt -q nullglob && NGV="-s" || NGV="-u" # Store the value for later.
6364
shopt -s nullglob # Without this, anything that doesn't exist in the filesystem turns into */*/*/...
6465

65-
while [[ "$end" ]] && ((${#shortenedpath} > maxlength)); do
66+
while [[ "${end}" ]] && ((${#shortenedpath} > maxlength)); do
6667
current="${end%%/*}" # everything before the first /
6768
end="${end#*/}" # everything after the first /
6869

@@ -71,10 +72,10 @@ _swd() {
7172

7273
for ((i = ${#current} - 2; i >= 0; i--)); do
7374
subcurrent="${current:0:i}"
74-
matching=("$begin/$subcurrent"*) # Array of all files that start with $subcurrent.
75-
((${#matching[*]} != 1)) && break # Stop shortening if more than one file matches.
76-
shortcur="$subcurrent"
77-
shortcurstar="$subcurrent*"
75+
matching=("${begin}/${subcurrent}"*) # Array of all files that start with $subcurrent.
76+
((${#matching[*]} != 1)) && break # Stop shortening if more than one file matches.
77+
shortcur="${subcurrent}"
78+
shortcurstar="${subcurrent}*"
7879
done
7980

8081
#advance
@@ -88,6 +89,7 @@ _swd() {
8889

8990
# Replaces slashes with  except first occurence.
9091
if [ $INHOME -eq 1 ]; then
92+
# shellcheck disable=SC2088
9193
echo "~/$shortenedpath" | sed "s/\///2g" # make sure it starts with ~/
9294
else
9395
echo "/$shortenedpath" | sed "s/\///2g" # Make sure it starts with /

themes/standard/standard.theme.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ case $TERM in
2121
esac
2222

2323
function prompt_command() {
24+
# shellcheck disable=SC2016
2425
PROMPT='${green?}\u${normal?}@${green?}\h${normal?}:${blue?}\w${normal?}${red?}$(prompt_char)$(git_prompt_info)${normal?}\$ '
2526
}
2627

themes/zitron/zitron.theme.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function prompt_command() {
2020
# user:host:pwd git-branch(*)$
2121
# for example:
2222
# noqqe:deathstar:themes master*$
23-
PS1="${no_color}\u:$(hostname)${normal?}:${bold_yellow?}\W/${normal?} $(git_prompt_info)${reset_color?}$ "
23+
PS1="${no_color?}\u:$(hostname)${normal?}:${bold_yellow?}\W/${normal?} $(git_prompt_info)${reset_color?}$ "
2424
}
2525

2626
safe_append_prompt_command prompt_command

0 commit comments

Comments
 (0)