bash脚本调用vi表示手动编辑,然后恢复脚本? [英] Bash script calls vi for manual editing, then script resumes?

查看:95
本文介绍了bash脚本调用vi表示手动编辑,然后恢复脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了验证使用SED在文本文件中的一些语法一个脚本,创建一个文本文件的备份,并且第二个脚本。

I wrote a script that creates a backup of a text file, and a second script that verifies some syntax in text file using SED.

在中间,有一个手动过程:用户编辑原始文件中添加一些字符串。这个过程必须保持手册。

In the middle, there is a manual process: Users edit the original file adding some strings. This process must remain manual.

我想我的合并两个脚本所以创建的备份,VI是开放的用户,当用户完成编辑文件,脚本重新开始做语法验证。

I would like to merge my two scripts so the backup is created, vi is open for the user, when the user is done editing the file, the script resumes doing the syntax verification.

我边学边做,但真的不知道如何code中的打开VI,等待用户做他的编辑,接管控制和验证恢复的一部分。

I am learning by doing, but really do not know how to code the "open vi, wait for the user to do his editing, take control over and resume with verification" part.

我看有可能被使用的函数调用系统(在Perl),但我的code在BASH。

I read there is a function called system (in Perl) that could be used, but my code is in BASH.

这是如何得到这个在BASH做有什么建议?谢谢!

Any suggestions on how to get this done in BASH? Thanks!

推荐答案

庆典,每个语句基本上喜欢隐式调用系统(除非它是一个内置的shell命令),因为shell脚本的设计可以很容易地运行其他程序。

In bash, each statement is essentially like an implicit call to system (unless it's a builtin shell command) since shell scripts are designed to make it easy to run other programs.

backup some_file.txt
vi some_file.txt  # The script blocks until the user exits vi
verify_syntax some_file.txt

使用之间的唯一区别键,如 LS命令 LS 将尽自己的事情和退出,无需用户干预,而(或任何交互式命令)将运行,直到用户明确退出。

The only difference between using vi and a command like ls is that ls will do its thing and exit without user intervention, while vi (or any interactive command) will run until the user explicitly exits.

这篇关于bash脚本调用vi表示手动编辑,然后恢复脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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