Edit shell script while it's running

前端 未结 11 1920
余生分开走
余生分开走 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:50

    Good question! Hope this simple script helps

    #!/bin/sh
    echo "Waiting..."
    echo "echo \"Success! Edits to a .sh while it executes do affect the executing script! I added this line to myself during execution\"  " >> ${0}
    sleep 5
    echo "When I was run, this was the last line"
    

    It does seem under linux that changes made to an executing .sh are enacted by the executing script, if you can type fast enough!

提交回复
热议问题