我想重新实现我自己的getopts(如果可能,请在python中)。getopts如何设置bash变量
我的问题是,我不明白这是怎么可能的:
# The call of the following script
./script -h
#!/bin/bash
getopts 'h' TEST # output nothing
echo $TEST # output h
env | grep # output nothing
我们读遍,你不能在父进程设置一个变量互联网。但是,这是在这里完成的,没有出口。
我想了解它是如何工作的,因为我想在python中做大致相同的操作。所以我的第二个问题是,是否有可能在python中做同样的事情?
非常感谢! :)
简单:'getopts'没有运行在子进程中。 – chepner