尽管lmod从7.4版本开始支持fish,但我必须使用旧版本的服务器。我如何使其与鱼共存? (即使容量有限。)
答案 0 :(得分:0)
该解决方案使我可以运行诸如module load R
之类的命令。在一般情况下可能会失败。
定义便利功能如下:
function module
eval $LMOD_CMD bash $argv | lmod_bash_to_fish.py | source -
end
其中lmod_bash_to_fish.py
具有以下内容:
#!/usr/bin/env python3
import re
import sys
f = sys.stdin
while True:
line = f.readline()
if not line:
break
match = re.match(r'^(\w+)="(.+)";\n$', line)
if not match:
raise RuntimeError("Unexpected line: {}".format(line))
var, val = match.groups()
line = f.readline()
if line != "export {};\n".format(var):
raise RuntimeError("Variable not immediately exported: {}".format(line))
if var == 'PATH':
val = " ".join('"{}"'.format(elem) for elem in val.split(':'))
print("set -gx fish_user_paths {}".format(val))
continue
print("set -gx {} \"{}\"".format(var, val))