欧美成人午夜免费全部完,亚洲午夜福利精品久久,а√最新版在线天堂,另类亚洲综合区图片小说区,亚洲欧美日韩精品色xxx

千鋒扣丁學(xué)堂Linux培訓(xùn)之shell中長命令換行處理方法示例

2019-07-11 13:25:19 2415瀏覽

今天千鋒扣丁學(xué)堂Linux培訓(xùn)老師給大家分享一篇關(guān)于shell中長命令的換行處理方法,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者使用shell具有一定的參考學(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進行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\ # 目標(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)致整個shell腳本解析失敗。

實測發(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í)行。

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

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

以上就是關(guān)于千鋒扣丁學(xué)堂Linux培訓(xùn)之shell中長命令換行處理方法示例的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,想要學(xué)好Linux開發(fā)小編給大家推薦口碑良好的扣丁學(xué)堂,扣丁學(xué)堂有專業(yè)老師制定的Linux學(xué)習(xí)路線圖輔助學(xué)員學(xué)習(xí),此外還有與時俱進的Linux課程體系和Linux視頻教程供大家學(xué)習(xí),想要學(xué)好Linux開發(fā)技術(shù)的小伙伴快快行動吧??鄱W(xué)堂Linux技術(shù)交流群:422345477。


                          【掃碼進入HTML5VIP免費公開課】  


     【關(guān)注微信公眾號獲取更多學(xué)習(xí)資料】        【掃碼進入HTML5前端開發(fā)VIP免費公開課】



查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>

標(biāo)簽: Linux培訓(xùn) Linux視頻教程 紅帽Linux視頻 Linux學(xué)習(xí)視頻 Linux入門視頻 紅帽RHCE/RHCSA考試

熱門專區(qū)

暫無熱門資訊

課程推薦

微信
微博
15311698296

全國免費咨詢熱線

郵箱:codingke@1000phone.com

官方群:148715490

北京千鋒互聯(lián)科技有限公司版權(quán)所有   北京市海淀區(qū)寶盛北里西區(qū)28號中關(guān)村智誠科創(chuàng)大廈4層
京ICP備2021002079號-2   Copyright ? 2017 - 2022
返回頂部 返回頂部