5d5d202794ad62c51435798fdd464245f928e5db

Author
Jakob Probst <jakob@probstfamilie.de>
Committer
Jakob Probst <jakob@probstfamilie.de>
Date

Message

Echo to Error-Stream. Double quote to prevent globbing and word splitting.

Diff

 1diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh
 2index 8edf81d54b69b1898df0098406ac5431bfeb2dc9..e250397be2387793227050de2ab90b80ff5f530f 100644
 3--- a/plugins/colorize/colorize.plugin.zsh
 4+++ b/plugins/colorize/colorize.plugin.zsh
 5@@ -5,36 +5,36 @@ alias cless='colorize_via_pygmentize_less'
 6 colorize_via_pygmentize() {
 7     local available_tools=("chroma" "pygmentize")
 8 
 9-    if [ -z $ZSH_COLORIZE_TOOL ]; then
10+    if [ -z "$ZSH_COLORIZE_TOOL" ]; then
11         if (( $+commands[pygmentize] )); then
12             ZSH_COLORIZE_TOOL="pygmentize"
13         elif (( $+commands[chroma] )); then
14             ZSH_COLORIZE_TOOL="chroma"
15         else
16-            echo "Neither 'pygments' nor 'chroma' is installed!"
17+            echo "Neither 'pygments' nor 'chroma' is installed!" >&2
18             return 1
19         fi
20     fi
21 
22     if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
23-        echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'."
24+        echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
25         return 1
26     elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
27-        echo "Package '$ZSH_COLORIZE_TOOL' is not installed!"
28+        echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
29         return 1
30     fi
31 
32     # If the environment variable ZSH_COLORIZE_STYLE
33     # is set, use that theme instead. Otherwise,
34     # use the default.
35-    if [ -z $ZSH_COLORIZE_STYLE ]; then
36+    if [ -z "$ZSH_COLORIZE_STYLE" ]; then
37         # Both pygmentize & chroma support 'emacs'
38         ZSH_COLORIZE_STYLE="emacs"
39     fi
40 
41     # pygmentize stdin if no arguments passed
42     if [ $# -eq 0 ]; then
43-        if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then
44+        if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
45             pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
46         else
47             chroma --style="$ZSH_COLORIZE_STYLE"
48@@ -48,7 +48,7 @@ colorize_via_pygmentize() {
49     local FNAME lexer
50     for FNAME in "$@"
51     do
52-        if [[ $ZSH_COLORIZE_TOOL == "pygmentize" ]]; then
53+        if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
54             lexer=$(pygmentize -N "$FNAME")
55             if [[ $lexer != text ]]; then
56                 pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"