婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > shell中長命令的換行處理方法示例

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

熱門標簽:外呼系統的合法性 武漢語音電銷機器人加盟 房產證地圖標注的兩個面積 同花順電話機器人微信 北京電銷機器人對市場的影響 輝縣市地圖標注 湖北孝感如何辦理 地圖標注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

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

換行

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

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

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) 換行后,整體閱讀體驗好了很多。進一步,我們想要為每個參數添加注釋,發現不能簡單地這樣來:

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

這樣會導致整個 shell 腳本解析失敗。

實測發現,也不能這樣:

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

同樣會導致解析失敗。

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

但也不是沒辦法添加注釋了,幾經周轉發現如下寫法是可行的:

emcc -o ./dist/test.html `# 目標文件` \

 --shell-file ./tmp.html `# 模板文件` \

 --source-map-base dist `# source map 根路徑` \

 -O3 `# 優化級別` \

 -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) 來包裹我們的注釋,就不會破壞掉腳本的語義了,能夠正確解析執行。

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

emcc -o ./dist/test.html `# 目標文件` \

 --shell-file ./tmp.html `# 模板文件` \

 --source-map-base dist `# source map 根路徑` \

 -O3 `# 優化級別` \

 -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

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。

您可能感興趣的文章:
  • shell腳本echo輸出不換行功能增強實例
  • PowerShell中刪除空格、點號、減號和換行方法代碼實例
  • PowerShell腳本反引號用法實例:隨時隨地給代碼換行

標簽:紹興 武威 蚌埠 西寧 麗江 迪慶 安康 日喀則

巨人網絡通訊聲明:本文標題《shell中長命令的換行處理方法示例》,本文關鍵詞  shell,中長,命令,的,換行,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《shell中長命令的換行處理方法示例》相關的同類信息!
  • 本頁收集關于shell中長命令的換行處理方法示例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 板桥市| 揭西县| 辽阳县| 济源市| 华宁县| 深泽县| 绵阳市| 格尔木市| 巧家县| 永靖县| 新晃| 图们市| 灵丘县| 红桥区| 宜宾市| 石阡县| 中阳县| 开鲁县| 深水埗区| 南京市| 开封县| 丰镇市| 咸阳市| 皋兰县| 镶黄旗| 泸定县| 革吉县| 梁河县| 余干县| 呼和浩特市| 阿巴嘎旗| 开封县| 广州市| 青田县| 应用必备| 邓州市| 阜阳市| 西城区| 崇信县| 延吉市| 剑川县|