gpt4 book ai didi

Linux TCshell 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 09:07:15 31 4
gpt4 key购买 nike

我已经为 TCsh shell 编写了一个简单的 shell 脚本。代码只是从用户那里获取输入,然后根据输入运行一些东西。我为此使用了 switch case,但我的问题是我输入的任何内容都会结束up 执行默认情况。

#!bin/tcsh
echo "creating workdir = setup "
echo "extracting = extract"
echo "creating setups= create "
echo "validate = all(for running all validation),ve ,fa ,annotate ,Lib, CDL"
set user_input = "$<"
echo "entered string is -" $user_input
switch (user_input)
case setup:
./validateSource -sc -setup -check ve fa annotate Lib CDL -source source -library library -reference reference
breaksw
case extract:
./validateSource -sc -extract -check ve fa annotate Lib CDL -source source -library library -reference reference
breaksw
case (create):
./validateSource -sc -create -check ve fa annotate Lib CDL -source source -library library -reference reference -workdir workdir_nowb_EDA_7p2
breaksw
case (all):
./validateSource -sc -validate -check ve fa annotate Lib CDL -workdir workdir_nowb_EDA_7p2 -force
breaksw
case (ve):
./validateSource -sc -validate -check ve -workdir workdir_nowb_EDA_7p2 -force
breaksw
case (fa):
./validateSource -sc -fa -check ve -workdir workdir_nowb_EDA_7p2 -force
breaksw
case (annotate):
./validateSource -sc -validate -check annotate -workdir workdir_nowb_EDA_7p2 -force
breaksw
case (Lib):
./validateSource -sc -validate -check Lib -workdir workdir_nowb_EDA_7p2 -force
breaksw
case (CDL) :
./validateSource -sc -validate -check CDL -workdir workdir_nowb_EDA_7p2 -force
breaksw
default :
echo "wrong string entered"
endsw

最佳答案

阅读名著csh considered harmful纸。

考虑使用另一个 shell 。最便携的就是限制自己posix shell (使用 dashbash 甚至 zsh 在正确配置时提供良好的合规性)。

我更喜欢 zsh

要调试您的 shell 脚本,请尝试将 -v-x 传递给 shell,例如/bin/tcsh -x -v yourshellscript

关于Linux TCshell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8429007/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com