Emacs的工作流编辑的bash脚本在运行时需要 [英] Emacs workflow to edit Bash scripts while they run

查看:123
本文介绍了Emacs的工作流编辑的bash脚本在运行时需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bash可以给意外的结果,如果一个在脚本运行编辑的脚本。但是,如果经常是能够编辑,我一个shell中运行脚本的临时副本很方便,但要确保它是回到原来​​的位置之前,我再次运行。有没有人有一个工作流或自定义Emacs的建议,以推动这一?

Bash can give unexpected results if one edits a script while the script is running. But it would often be very convenient to be able to edit a temporary copy of a script that I run within a shell, but make sure it is back in the original location before I run it again. Does anyone have suggestions for a workflow or customizations to Emacs to facilitate this?

推荐答案

的Mx删除文件,preSS 下跌插入获得的路径,你正在编辑的文件, RET 删除文件。当您下一次保存您的缓冲,这将创建一个新的文件。巴什将继续执行旧的,删除的文件。

M-x delete-file, press down to insert obtain the path to the file you're editing, and RET to delete the file. When you next save your buffer, this will create a new file. Bash will keep executing the old, deleted file.

顺便说一句,在大多数情况下,你甚至不需要借此precaution。 Emacs的通常保存到一个临时文件,然后重命名该临时文件,以正确的文件名(删除旧文件,除非它被保留作为备份)。如果该文件有硬链接,或者如果你没有对目录的写入权限:Emacs的,只有当它检测到它不能正确地重新创建该文件覆盖的地方文件。 (我简化了一点;细节是在基本保存缓冲-2 函数 files.el )。只要文件有一个单独的目录条目,你必须在包含脚本的目录的写权限,只需preSS CX铯

By the way, in most cases, you don't even need to take this precaution. Emacs usually saves to a temporary file, then renames that temporary file to the proper file name (which deletes the old file, unless it's being kept as a backup). Emacs only overwrites the file in place if it detects that it can't recreate the file properly: if the file has hard links, or if you don't have write permission on the directory. (I'm simplifying a little; the details are in the basic-save-buffer-2 function in files.el.) As long as the file has a single directory entry and you have write permissions on the directory containing the script, just press C-x C-s.

这篇关于Emacs的工作流编辑的bash脚本在运行时需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆