Edit shell script while it's running

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

    Break your script into functions, and each time a function is called you source it from a separate file. Then you could edit the files at any time and your running script will pick up the changes next time it gets sourced.

    foo() {
      source foo.sh
    }
    foo
    

提交回复
热议问题