The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
Opening a text editor (Vi, emacs) from within script
So, if you've used SVN, you know that it looks at your $EDITOR variable and opens that program whenever you try to make a commit without a memo line.
I'm trying to emulate that sort of behavior, how do I get something to edit a temporary file or a buffer in memory, and automatically return to the script's execution after the text editor exits?
I'm working in Ruby but am reasonably fluent in perl, but even a pointer in the right direction would help, my Google-fu on this subject was weak.
So, if you've used SVN, you know that it looks at your $EDITOR variable and opens that program whenever you try to make a commit without a memo line.
I'm trying to emulate that sort of behavior, how do I get something to edit a temporary file or a buffer in memory, and automatically return to the script's execution after the text editor exits?
I'm working in Ruby but am reasonably fluent in perl, but even a pointer in the right direction would help, my Google-fu on this subject was weak.
I just tried this in Perl:
system("pico -w");
print "Done";
and it worked fine. You just have to find the right system call for Ruby. Obviously, you call the program in the $EDITOR variable.
For the other part of the problem, I believe you have to create the temporary file in whatever language you are using. Then, just open an editor that is editing that file, and check it for modification as soon as the call exists.
For the other part of the problem, I believe you have to create the temporary file in whatever language you are using. Then, just open an editor that is editing that file, and check it for modification as soon as the call exists.
Cool, for some reason I thought that system calls behaved like forks, in that the execution of the program would still continue.
For the other part of the problem, I believe you have to create the temporary file in whatever language you are using. Then, just open an editor that is editing that file, and check it for modification as soon as the call exists.
Cool, for some reason I thought that system calls behaved like forks, in that the execution of the program would still continue.
Every scripting language I know of has both fork style calls (exec() in Perl) and execute and wait (system() in Perl). Scripting stuff would be hard if you couldn't wait for programs to return a value
I expect, but don't know, that text editors will probably return a truth value depending on whether they saved out the file they were supposed to. You might want to check that, it's easier than checking for the file to have been modified by comparison.
Posts
I just tried this in Perl:
and it worked fine. You just have to find the right system call for Ruby. Obviously, you call the program in the $EDITOR variable.
Cool, for some reason I thought that system calls behaved like forks, in that the execution of the program would still continue.
I did the following and it worked swimmingly:
Please lock this thread for posterity.
Every scripting language I know of has both fork style calls (exec() in Perl) and execute and wait (system() in Perl). Scripting stuff would be hard if you couldn't wait for programs to return a value
I expect, but don't know, that text editors will probably return a truth value depending on whether they saved out the file they were supposed to. You might want to check that, it's easier than checking for the file to have been modified by comparison.