Skip to content

Commit

Permalink
Fix for shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Apr 14, 2020
1 parent a0d3305 commit f6e194f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions lib/general.sh
Expand Up @@ -388,15 +388,19 @@ shellspec_ends_with_posix() {
case $1 in (*"$2") ;; (*) false ;; esac
}

# shellcheck disable=SC2154
shellspec_includes_fallback() {
shellspec_meta_escape shellspec_includes_fallback "$2"
eval "[ ! \"\${1#*$shellspec_includes_fallback}\" = \"\$1\" ] &&:" &&:
}

# shellcheck disable=SC2154
shellspec_starts_with_fallback() {
shellspec_meta_escape shellspec_starts_with_fallback "$2"
eval "[ ! \"\${1#$shellspec_starts_with_fallback*}\" = \"\$1\" ] &&:" &&:
}

# shellcheck disable=SC2154
shellspec_ends_with_fallback() {
shellspec_meta_escape shellspec_ends_with_fallback "$2"
eval "[ ! \"\${1%*$shellspec_ends_with_fallback}\" = \"\$1\" ] &&:" &&:
Expand Down
4 changes: 2 additions & 2 deletions lib/libexec/translator.sh
Expand Up @@ -283,7 +283,7 @@ parameters_generate_code() {
parameters_continuation_line() {
line=$1
shift
while ends_with "$line" '\'; do
while ends_with "$line" "\\"; do
read_specfile line ||:
"$@" "$line"
done
Expand Down Expand Up @@ -423,7 +423,7 @@ remove_from_ranges() {
translate() {
block_id='' inside_of_example='' inside_of_text='' work=''
while read_specfile line; do
while ends_with "$line" '\'; do
while ends_with "$line" "\\"; do
read_specfile work ||:
line="${line}${LF}${work}"
done
Expand Down
26 changes: 13 additions & 13 deletions spec/general_spec.sh
Expand Up @@ -337,8 +337,8 @@ Describe "general.sh"
End

Describe "characters"
Parameters:value '!' '"' '#' '$' '%' '&' '(' ')' '-' '=' '^' '~' '\' \
'|' '@' '`' '[' '{' ';' '+' ':' '*' ']' '}' '.' '>' '/' '?' '_' "'"
Parameters:value '!' '"' '#' '$' '%' '&' '(' ')' '-' '=' '^' '~' '|' " " \
'@' '`' '[' '{' ';' '+' ':' '*' ']' '}' '.' '<' '>' "\\" '?' '_' "'"
It "replaces all characters ($1)"
When call shellspec_replace_all replaced "A$1$1$1B$1$1$1C" "$1" "x"
The variable replaced should eq "AxxxBxxxC"
Expand All @@ -353,8 +353,8 @@ Describe "general.sh"
"abc[*]abc[*]" "[*]" "OK" "abcOKabcOK"
"= =" " " "OK" "=OKOKOK="
"=${lf}${lf}${lf}=" "$lf" "OK" "=OKOKOK="
'=\=' '\' "OK" "=OK="
'\' '\' "OK" "OK"
'=\=' "\\" "OK" "=OK="
"\\" "\\" "OK" "OK"
'!' '!' "!" "!"
End

Expand All @@ -380,8 +380,8 @@ Describe "general.sh"
End

Describe "characters"
Parameters:value '!' '"' '#' '$' '%' '&' '(' ')' '-' '=' '^' '~' '\' \
'|' '@' '`' '[' '{' ';' '+' ':' '*' ']' '}' '.' '>' '/' '?' '_' "'"
Parameters:value '!' '"' '#' '$' '%' '&' '(' ')' '-' '=' '^' '~' '|' " " \
'@' '`' '[' '{' ';' '+' ':' '*' ']' '}' '.' '<' '>' "\\" '?' '_' "'"
It "replaces all characters ($1)"
When call shellspec_replace_all_posix replaced "A$1$1$1B$1$1$1C" "$1" "x"
The variable replaced should eq "AxxxBxxxC"
Expand All @@ -396,8 +396,8 @@ Describe "general.sh"
"abc[*]abc[*]" "[*]" "OK" "abcOKabcOK"
"= =" " " "OK" "=OKOKOK="
"=${lf}${lf}${lf}=" "$lf" "OK" "=OKOKOK="
'=\=' '\' "OK" "=OK="
'\' '\' "OK" "OK"
'=\=' "\\" "OK" "=OK="
"\\" "\\" "OK" "OK"
'!' '!' "!" "!"
End

Expand All @@ -421,8 +421,8 @@ Describe "general.sh"
End

Describe "characters"
Parameters:value '!' '"' '#' '$' '%' '&' '(' ')' '-' '=' '^' '~' '\' '|' \
'@' '`' '[' '{' ';' '+' ':' '*' ']' '}' '.' '<' '>' '/' '?' '_' "'" " "
Parameters:value '!' '"' '#' '$' '%' '&' '(' ')' '-' '=' '^' '~' '|' " " \
'@' '`' '[' '{' ';' '+' ':' '*' ']' '}' '.' '<' '>' "\\" '?' '_' "'"
It "replaces all characters ($1)"
When call shellspec_replace_all_fallback replaced "A$1$1$1B$1$1$1C" "$1" "x"
The variable replaced should eq "AxxxBxxxC"
Expand All @@ -440,8 +440,8 @@ Describe "general.sh"
"=${tab}${tab}${tab}=" "$tab" "OK" "=OKOKOK="
"=${vt}${vt}${vt}=" "$vt" "OK" "=OKOKOK="
"=${cr}${cr}${cr}=" "$cr" "OK" "=OKOKOK="
'=\=' '\' "OK" "=OK="
'\' '\' "OK" "OK"
'=\=' "\\" "OK" "=OK="
"\\" "\\" "OK" "OK"
'!' '!' "!" "!"
'^' '^' "^" "^"
End
Expand Down Expand Up @@ -598,7 +598,7 @@ Describe "general.sh"
Describe "shellspec_trim()"
It 'trims white space'
When call shellspec_trim value " $IFS abc $IFS "
The value "$value" should eq 'abc'
The variable value should eq 'abc'
End
End

Expand Down

0 comments on commit f6e194f

Please sign in to comment.