You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Application/resources/colorize.sh
+62-50
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
#
6
6
# Copyright 2007 Nathaniel Gray.
7
7
# Copyright 2012-2018 Anthony Gelibert.
8
+
# Copyright 2019-2023 Sbarex.
8
9
#
9
10
# Expects $1 = name of file to colorize
10
11
#
@@ -52,9 +53,7 @@ dos2unix="$pathDos2unix"
52
53
if [ "x${targetHL}"="x" ];then
53
54
echo"Error: missing target env!">>${err_device}
54
55
exit 1
55
-
fi
56
-
57
-
if [[ !-a"$targetHL" ]];then
56
+
elif [[ !-a"$targetHL" ]];then
58
57
echo"Error: missing target file!">>${err_device}
59
58
exit 1
60
59
fi
@@ -71,58 +70,71 @@ if [ "x${textEncoding}" = "x" ]; then
71
70
textEncoding="UTF-8"
72
71
fi
73
72
74
-
debug "Starting colorize.sh"
73
+
debug 'Starting `colorize.sh`'
75
74
ifhash gdate 2>/dev/null;then
76
75
else
77
-
debug "# install gdate with \`brew install coreutils\` to show the nanoseconds time stamp #"
76
+
debug '# Install `gdate` with `brew install coreutils` to show the nanoseconds time stamp #'
78
77
fi
79
78
79
+
# Se il percorso del file viene passato tra doppi apici (che comportano l'espansione delle varibili che iniziano con $) è necessario proteggere nel valore i caratteri doppio apice e dollaro:
80
+
# - protegge gli apici doppi " con \" e gli $ con \$.
81
+
# - gli apici singoli ' non devono essere protetti dato che il percorso è racchiuso tra doppi apici.
82
+
escaped_targetHL=$(echo ${targetHL}| sed "s/\"/\\\\\"/g;s/\\\$/\\\\\$/g")
83
+
84
+
# Se il percorso del file viene passato tra apici singoli (che non comportano l'espansione delle varibili e l'interpretazione di caratteri speciali) è necessario proteggere nel valore il carattere apice singolo:
85
+
# - protegge gli apici singoli ' sostituendoli con '"'"'
86
+
# - gli apici doppi " e $ non devono essere protetti dato che il percorso è racchiuso tra apici singoli.
87
+
# https://stackoverflow.com/a/1250279/1409904
88
+
# https://stackoverflow.com/a/42082956/1409904
89
+
escaped_targetHL=$(echo ${targetHL}| sed "s/'/'\"'\"'/g")
90
+
91
+
80
92
# Reader used to get the contents of the target file.
0 commit comments