jovanbulck / jsh

A basic UNIX shell implementation in C
GNU General Public License v3.0
30 stars 10 forks source link

jsh update #19

Closed KevinMordijck closed 9 years ago

KevinMordijck commented 9 years ago

when using the shell, it is not possible to update the shell to a newer version because of next error: "cp: cannot create regular file ‘/opt/jsh’: Text file busy"

jovanbulck commented 9 years ago

idea: write a new built_in jsh-update <path to fresh jsh binary> that implements something like this:

This should work, according to http://www.linuxquestions.org/questions/linux-general-1/cannot-create-regular-file-text-file-busy-731644/

jovanbulck commented 9 years ago

maybe it's a lot easier: just use cp with the -f flag . From the cp man page: "if an existing destination file cannot be opened, remove it and try again". Note that this should work as the OS will keep the old 'removed' executable as long as a process (the running jsh session) is using it...

See also: http://helpful.knobs-dials.com/index.php/Text_file_busy and https://github.com/antirez/redis/issues/335

jovanbulck commented 9 years ago

the new makefile uses the install UNIX command that takes care of all this :-)

Just try sudo make install in the project dir will auto copy the jsh binary to /usr/share/local/bin Simple as can be :D

(note: don't forget to remove old /opt/jsh binaries; if any since typing jsh in the shell can otherwise resolve to the old binary if /opt is fist in the $PATH ...