[Github-comments] [geany/geany] NSIS upgrade to 3.x (#2181)
Enrico Tröger
notifications at xxxxx
Thu Jun 20 10:59:07 UTC 2019
eht16 commented on this pull request.
> +
+# extract variable names (then sort the result, conver to lowercase and replace new lines by spaces)
+variables=$(\
+ sed --silent --regexp-extended\
+ --expression 's/^[ ]*m_ShellConstants.add\(_T\("(.*)"\),.*,.*\);.*$/\1/p' \
+ --expression 's/^[ ]*m_UserVarNames.add\(_T\("(.*)"\),.*\);.*$/\1/p' "${BUILD_CPP_FILE}" | \
+ sort | \
+ tr '[:upper:]' '[:lower:]' | \
+ tr '\n' ' ')
+
+# hardcode a few more, as found in the documentation ("4.2.2 Other Writable Variables")
+variables_extra='{nsisdir} 0 1 2 3 4 5 6 7 8 9 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 \\n \\r \\t $'
+variables="${variables_extra} ${variables}"
+# prefix each element with a dollar sign
+declare -a variables_array=(${variables})
+variables="${variables_array[@]/#/'$'}"
As you say, Mr. `sed` :)
While I don't mind much about the Bash dependency (this is a maintenance script to be run only by developers and only if necessary and so doesn't need to be that portable), I like the `sed` approach more than the array magic because of readability.
Thanks.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2181#discussion_r295753959
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20190620/7112efb1/attachment.html>
More information about the Github-comments
mailing list