Edit shell script while it's running

前端 未结 11 1788
余生分开走
余生分开走 2020-11-27 03:18

Can you edit a shell script while it\'s running and have the changes affect the running script?

I\'m curious about the specific case of a csh script I have that batc

11条回答
  •  抹茶落季
    2020-11-27 03:48

    I don't have csh installed, but

    #!/bin/sh
    echo Waiting...
    sleep 60
    echo Change didn't happen
    

    Run that, quickly edit the last line to read

    echo Change happened
    

    Output is

    Waiting...
    /home/dave/tmp/change.sh: 4: Syntax error: Unterminated quoted string
    

    Hrmph.

    I guess edits to the shell scripts don't take effect until they're rerun.

提交回复
热议问题