目前我正在尝试验证包含路径的字符串是否包含特定字符串。
我已经尝试过 bash 比较:
和
我也尝试使用“包含”关键字。但我不确定我是否想将它与字符串一起使用..
不幸的是,这些尝试都失败了。:/
function next_dir
set foundcwd 0
set cwd $PWD
set error 'There is no next directory to navigate to...'
if [ -z $cwd ]
echo $error
else
echo $cwd
for d in ../*/
set needle (string split "/" -- $d)[2]
if [ $foundcwd = 1 ]
cd $d
break
end
if [ $cwd =~ $needle ]
$foundcwd = 1
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
我的函数的目标是导航到下一个(同级)目录。
/mnt/c/workingdirectory/repoA --> 当前目录 /mnt/c/workingdirectory/repoB --> 导航到 repoB
归档时间: |
|
查看次数: |
353 次 |
最近记录: |