国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Linux > 正文

shell中長命令的換行處理方法示例

2019-10-26 18:59:58
字體:
供稿:網(wǎng)友

前言

考察下面的腳本:

emcc -o ./dist/test.html --shell-file ./tmp.html --source-map-base dist -O3 -g4 --source-map-base dist -s MODULARIZE=1 -s "EXPORT_NAME=/"Test/"" -s USE_SDL=2 -s LEGACY_GL_EMULATION=1 --pre-js ./pre.js --post-js ./post.js --cpuprofiler --memoryprofiler --threadprofilermain.cpp

這里在調(diào)用 emcc 進行 WebAssembly 編譯時,組織了很多參數(shù)。整個命令都在一行之中,不是很好閱讀和維護。

換行

可通過加 / 的方式來進行換行拆分。

改造后看起來像這樣,一個參數(shù)占一行:

emcc -o ./dist/test.html/ --shell-file ./tmp.html/ --source-map-base dist/ -O3/ -g4/ --source-map-base dist/ -s MODULARIZE=1/ -s "EXPORT_NAME=/"Test/""/ -s USE_SDL=2/ -s LEGACY_GL_EMULATION=1/ --pre-js ./pre.js/ --post-js ./post.js/ --cpuprofiler/ --memoryprofiler/ --threadprofiler/ main.cpp

注釋

通過 /(backslash) 換行后,整體閱讀體驗好了很多。進一步,我們想要為每個參數(shù)添加注釋,發(fā)現(xiàn)不能簡單地這樣來:

emcc -o ./dist/test.html/ # 目標文件 --shell-file ./tmp.html/ # 模板文件 --source-map-base dist/ -O3/ -g4/ --source-map-base dist/ -s MODULARIZE=1/ -s "EXPORT_NAME=/"Test/""/ -s USE_SDL=2/ -s LEGACY_GL_EMULATION=1/ --pre-js ./pre.js/ --post-js ./post.js/ --cpuprofiler/ --memoryprofiler/ --threadprofiler/ main.cpp

這樣會導(dǎo)致整個 shell 腳本解析失敗。

實測發(fā)現(xiàn),也不能這樣:

emcc -o/ # 目標文件 ./dist/test.html/   # 模板文件 --shell-file ./tmp.html/ --source-map-base dist/ -O3/ -g4/ --source-map-base dist/ -s MODULARIZE=1/ -s "EXPORT_NAME=/"Test/""/ -s USE_SDL=2/ -s LEGACY_GL_EMULATION=1/ --pre-js ./pre.js/ --post-js ./post.js/ --cpuprofiler/ --memoryprofiler/ --threadprofiler/ main.cpp

同樣會導(dǎo)致解析失敗。

說到底,通過 / 拆分的命令,只是呈現(xiàn)上變成了多行,其中插入的注釋是會破壞掉語義的。

但也不是沒辦法添加注釋了,幾經(jīng)周轉(zhuǎn)發(fā)現(xiàn)如下寫法是可行的:

emcc -o ./dist/test.html `# 目標文件` / --shell-file ./tmp.html `# 模板文件` / --source-map-base dist `# source map 根路徑` / -O3 `# 優(yōu)化級別` / -g4 `# 生成 debug 信息` / --source-map-base dist/ `# -s MODULARIZE=1/` -s "EXPORT_NAME=/"Test/""/ -s USE_SDL=2/ -s LEGACY_GL_EMULATION=1/ --pre-js ./pre.js/ --post-js ./post.js/ --cpuprofiler/ --memoryprofiler/ --threadprofiler/ main.cpp

即通過 `(backtick) 來包裹我們的注釋,就不會破壞掉腳本的語義了,能夠正確解析執(zhí)行。

進一步,解決了注釋的問題,如果我們不想要某一行,同時又不想刪除,可以像下面這樣來注釋:

emcc -o ./dist/test.html `# 目標文件` / --shell-file ./tmp.html `# 模板文件` / --source-map-base dist `# source map 根路徑` / -O3 `# 優(yōu)化級別` / -g4 `# 生成 debug 信息` / --source-map-base dist/ -s MODULARIZE=1/ -s "EXPORT_NAME=/"Test/""/ -s USE_SDL=2/ -s LEGACY_GL_EMULATION=1/ `# --pre-js ./pre.js`/ --post-js ./post.js/ --cpuprofiler/ `# --threadprofiler`/ --memoryprofiler/ main.cpp            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 涿鹿县| 嘉黎县| 三台县| 西峡县| 沂南县| 合阳县| 新河县| 金昌市| 益阳市| 大名县| 来安县| 会昌县| 自治县| 二连浩特市| 乌审旗| 陆川县| 阿巴嘎旗| 朔州市| 永胜县| 光泽县| 丘北县| 南丹县| 徐水县| 英超| 武冈市| 和平区| 外汇| 丁青县| 天津市| 上栗县| 大庆市| 绥宁县| 五台县| 慈利县| 彭阳县| 平山县| 平阴县| 邵东县| 马关县| 航空| 海门市|