最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2019年07月11日 11:06:28   作者:劉哇勇的部落格  
這篇文章主要給大家介紹了關(guān)于shell中長命令的換行處理方法,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用shell具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧

前言

考察下面的腳本:

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 進(jìn)行 WebAssembly 編譯時(shí),組織了很多參數(shù)。整個(gè)命令都在一行之中,不是很好閱讀和維護(hù)。

換行

可通過加 \ 的方式來進(jìn)行換行拆分。

改造后看起來像這樣,一個(gè)參數(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) 換行后,整體閱讀體驗(yàn)好了很多。進(jìn)一步,我們想要為每個(gè)參數(shù)添加注釋,發(fā)現(xiàn)不能簡單地這樣來:

emcc -o ./dist/test.html\ # 目標(biāo)文件
 --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)致整個(gè) shell 腳本解析失敗。

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

emcc -o\
 # 目標(biā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 `# 目標(biāo)文件` \
 --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í)行。

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

emcc -o ./dist/test.html `# 目標(biāo)文件` \
 --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

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對腳本之家的支持。

相關(guān)文章

最新評論

顺昌县| 广丰县| 开远市| 扎赉特旗| 同仁县| 岐山县| 荔波县| 绍兴县| 五河县| 新乡县| 拉孜县| 阜康市| 安康市| 黑河市| 运城市| 商都县| 鄂温| 张北县| 承德市| 萨嘎县| 临武县| 灵宝市| 南乐县| 河曲县| 乌苏市| 桂阳县| 武邑县| 仲巴县| 五常市| 边坝县| 莱西市| 东海县| 丘北县| 宝山区| 石渠县| 崇礼县| 汝城县| 裕民县| 金山区| 喜德县| 微博|