shell – 从Emacs运行多字符串bash脚本
发布时间:2020-12-15 21:57:55 所属栏目:安全 来源:网络整理
导读:我想运行以下bash脚本,该脚本存储在Elisp字符串中,而不是存储在.sh文件中,然后将 shell输出存储在变量中. #!/bin/bashIFS=: read -ra _dirs_in_path "$PATH"for _dir in "${_dirs_in_path[@]}"; do for _file in "${_dir}"/*; do [[ -x ${_file} -f ${_file}
我想运行以下bash脚本,该脚本存储在Elisp字符串中,而不是存储在.sh文件中,然后将
shell输出存储在变量中.
#!/bin/bash IFS=: read -ra _dirs_in_path <<< "$PATH" for _dir in "${_dirs_in_path[@]}"; do for _file in "${_dir}"/*; do [[ -x ${_file} && -f ${_file} ]] && printf '%sn' "${_file##*/}" done done 我无法在包含多个字符串的bash脚本上运行shell-command. Emacs and Long Shell Commands也没有帮助我,因为compile和comint-run也需要命令,而不是bash语法. 如何从Elisp运行复杂的bash脚本? 解决方法
多行命令可以作为参数提供给bash -c,如果你引用它们就像你可能包含shell元字符的任何其他shell参数一样,例如:
(setq my-command (concat "IFS=: read -ra dirs <<<"$PATH"n" "for dir in ${dirs[@]}; don" " echo got dir "$dir"n" "donen")) (shell-command (format "bash -c %s" (shell-quote-argument my-command))) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |