我正在尝试使用 shell 脚本修改我的 ace/ext-modelist.js,代码如下:
#!/bin/bash
# This script will prepare ace for running properly
RM_EXTENSIONS=(elastic_tabstops_lite chromevox emmet statusbar error_marker keybinding_menu old_ie textarea themelist static_highlight split spellcheck settings_menu)
RM_LANG=(abap cobol forth mushcode vbscript tcl velocity pascal powershell asciidoc apache_conf ada soy_template verilog vhdl autohotkey batchfile c9search)
# Sed like command using perl
# We need this because on OS X, sed does not support ignoring case
function PSED {
perl -C -e 'use utf8;' -i -pe $1 $2
}
# Remove useless extensions
for ext in ${RM_EXTENSIONS[*]}
do
echo "Remove extension $ext"
rm -f ace/ext-$ext.js
done
# Remove languages
for lang in ${RM_LANG[*]}
do
echo "Remove language $lang"
# Remove the files
rm -f "ace/mode-$lang.js" "ace/snippets/$lang.js" "ace/worker-$lang.js"
# Remove any references in ext-modelist
# Remove extension mapping
PSED "s/,?${lang}\:\[\"[^\"]+?\"\]//gi" ace/ext-modelist.js
# Remove readable name mapping
PSED "s/,?${lang}\:\"\w+\"//gi" ace/ext-modelist.js
done
# Cleanup our previous replaces
# Remove any bad comas left over from modelist
PSED "s/\{,/{/gi" ace/ext-modelist.js
PSED "s/,\}/{/gi" ace/ext-modelist.js
# Detect empty snippets
# using the value of their 'snippetText' variable
SREGEX="snippetText=(\"\"|\'\')"
# Remove empty snippet files
find ./ace/snippets -name "*.js" -print | \
xargs grep -E ${SREGEX} -l | \
xargs rm -f
# Remove useless themes
echo "Removes themes"
rm -rf ace/theme-*.js
问题是这一切都有效,除非我尝试修改ace/ext-modelist.js
我收到文件正忙于跳过文件错误。
我知道在 Windows 中运行 VM 是一个问题,因为它在 Mac 和 Linux 上运行良好,我已经通过 dos2unix 运行了所有文件,所以错误不在于 shell 脚本本身,可能是命令?
编辑:
使用 bash -x 运行并输出到日志文件后,出现以下错误:
+ RM_EXTENSIONS=(elastic_tabstops_lite chromevox statusbar emmet error_marker keybinding_menu old_ie textarea themelist static_highlight split spellcheck settings_menu)
+ RM_LANG=(abap cobol forth mushcode vbscript tcl velocity pascal powershell asciidoc apache_conf ada soy_template verilog vhdl autohotkey batchfile c9search)
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension elastic_tabstops_lite'
Remove extension elastic_tabstops_lite
+ rm -f ace/ext-elastic_tabstops_lite.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension chromevox'
Remove extension chromevox
+ rm -f ace/ext-chromevox.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension statusbar'
Remove extension statusbar
+ rm -f ace/ext-statusbar.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension emmet'
Remove extension emmet
+ rm -f ace/ext-emmet.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension error_marker'
Remove extension error_marker
+ rm -f ace/ext-error_marker.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension keybinding_menu'
Remove extension keybinding_menu
+ rm -f ace/ext-keybinding_menu.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension old_ie'
Remove extension old_ie
+ rm -f ace/ext-old_ie.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension textarea'
Remove extension textarea
+ rm -f ace/ext-textarea.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension themelist'
Remove extension themelist
+ rm -f ace/ext-themelist.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension static_highlight'
Remove extension static_highlight
+ rm -f ace/ext-static_highlight.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension split'
Remove extension split
+ rm -f ace/ext-split.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension spellcheck'
Remove extension spellcheck
+ rm -f ace/ext-spellcheck.js
+ for ext in '${RM_EXTENSIONS[*]}'
+ echo 'Remove extension settings_menu'
Remove extension settings_menu
+ rm -f ace/ext-settings_menu.js
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language abap'
Remove language abap
+ rm -f ace/mode-abap.js ace/snippets/abap.js ace/worker-abap.js
+ PSED 's/,?abap\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?abap\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?abap\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?abap\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language cobol'
Remove language cobol
+ rm -f ace/mode-cobol.js ace/snippets/cobol.js ace/worker-cobol.js
+ PSED 's/,?cobol\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?cobol\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?cobol\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?cobol\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language forth'
Remove language forth
+ rm -f ace/mode-forth.js ace/snippets/forth.js ace/worker-forth.js
+ PSED 's/,?forth\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?forth\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?forth\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?forth\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language mushcode'
Remove language mushcode
+ rm -f ace/mode-mushcode.js ace/snippets/mushcode.js ace/worker-mushcode.js
+ PSED 's/,?mushcode\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?mushcode\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?mushcode\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?mushcode\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language vbscript'
Remove language vbscript
+ rm -f ace/mode-vbscript.js ace/snippets/vbscript.js ace/worker-vbscript.js
+ PSED 's/,?vbscript\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?vbscript\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?vbscript\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?vbscript\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language tcl'
Remove language tcl
+ rm -f ace/mode-tcl.js ace/snippets/tcl.js ace/worker-tcl.js
+ PSED 's/,?tcl\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?tcl\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?tcl\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?tcl\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language velocity'
Remove language velocity
+ rm -f ace/mode-velocity.js ace/snippets/velocity.js ace/worker-velocity.js
+ PSED 's/,?velocity\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?velocity\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?velocity\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?velocity\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language pascal'
Remove language pascal
+ rm -f ace/mode-pascal.js ace/snippets/pascal.js ace/worker-pascal.js
+ PSED 's/,?pascal\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?pascal\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?pascal\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?pascal\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language powershell'
Remove language powershell
+ rm -f ace/mode-powershell.js ace/snippets/powershell.js ace/worker-powershell.js
+ PSED 's/,?powershell\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?powershell\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?powershell\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?powershell\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language asciidoc'
Remove language asciidoc
+ rm -f ace/mode-asciidoc.js ace/snippets/asciidoc.js ace/worker-asciidoc.js
+ PSED 's/,?asciidoc\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?asciidoc\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?asciidoc\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?asciidoc\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language apache_conf'
Remove language apache_conf
+ rm -f ace/mode-apache_conf.js ace/snippets/apache_conf.js ace/worker-apache_conf.js
+ PSED 's/,?apache_conf\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?apache_conf\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?apache_conf\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?apache_conf\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language ada'
Remove language ada
+ rm -f ace/mode-ada.js ace/snippets/ada.js ace/worker-ada.js
+ PSED 's/,?ada\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?ada\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?ada\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?ada\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language soy_template'
Remove language soy_template
+ rm -f ace/mode-soy_template.js ace/snippets/soy_template.js ace/worker-soy_template.js
+ PSED 's/,?soy_template\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?soy_template\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?soy_template\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?soy_template\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language verilog'
Remove language verilog
+ rm -f ace/mode-verilog.js ace/snippets/verilog.js ace/worker-verilog.js
+ PSED 's/,?verilog\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?verilog\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?verilog\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?verilog\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language vhdl'
Remove language vhdl
+ rm -f ace/mode-vhdl.js ace/snippets/vhdl.js ace/worker-vhdl.js
+ PSED 's/,?vhdl\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?vhdl\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?vhdl\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?vhdl\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language autohotkey'
Remove language autohotkey
+ rm -f ace/mode-autohotkey.js ace/snippets/autohotkey.js ace/worker-autohotkey.js
+ PSED 's/,?autohotkey\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?autohotkey\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?autohotkey\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?autohotkey\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language batchfile'
Remove language batchfile
+ rm -f ace/mode-batchfile.js ace/snippets/batchfile.js ace/worker-batchfile.js
+ PSED 's/,?batchfile\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?batchfile\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?batchfile\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?batchfile\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ for lang in '${RM_LANG[*]}'
+ echo 'Remove language c9search'
Remove language c9search
+ rm -f ace/mode-c9search.js ace/snippets/c9search.js ace/worker-c9search.js
+ PSED 's/,?c9search\:\["[^"]+?"\]//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?c9search\:\["[^"]+?"\]//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,?c9search\:"\w+"//gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,?c9search\:"\w+"//gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/\{,/{/gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/\{,/{/gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ PSED 's/,\}/{/gi' ace/ext-modelist.js
+ perl -C -e 'use utf8;' -i -pe 's/,\}/{/gi' ace/ext-modelist.js
Can't remove ace/ext-modelist.js: Text file busy, skipping file.
+ SREGEX='snippetText=(""|\'\''\'\'')'
+ xargs rm -f
+ xargs grep -E 'snippetText=(""|\'\''\'\'')' -l
+ find ./ace/snippets -name '*.js' -print
+ echo 'Removes themes'
Removes themes
+ rm -rf ace/theme-ambiance.js ace/theme-chaos.js ace/theme-chrome.js ace/theme-clouds.js ace/theme-clouds_midnight.js ace/theme-cobalt.js ace/theme-crimson_editor.js ace/theme-dawn.js ace/theme-dreamweaver.js ace/theme-eclipse.js ace/theme-github.js ace/theme-idle_fingers.js ace/theme-katzenmilch.js ace/theme-kr.js ace/theme-kuroir.js ace/theme-merbivore.js ace/theme-merbivore_soft.js ace/theme-mono_industrial.js ace/theme-monokai.js ace/theme-pastel_on_dark.js ace/theme-solarized_dark.js ace/theme-solarized_light.js ace/theme-terminal.js ace/theme-textmate.js ace/theme-tomorrow.js ace/theme-tomorrow_night_blue.js ace/theme-tomorrow_night_bright.js ace/theme-tomorrow_night_eighties.js ace/theme-tomorrow_night.js ace/theme-twilight.js ace/theme-vibrant_ink.js ace/theme-xcode.js