为什么在bash脚本中不使用两个cd命令执行第二个命令?
我编写了一个bash脚本,该脚本创建了一系列目录并将一个项目克隆到所选目录中。 为此,我需要访问cd每个目录(project 1和project 2),但是脚本不需要cd访问第二个目录,也不执行命令。 而是cd在project2目录克隆后停止。为什么cd_project1在下面的代码中不调用该函数? #!/bin/bash #Get the current user name function my_user_name() { current_user=$USER echo " Current user is $current_user" } #Creating useful directories function create_useful_directories() { if [[ ! -d "$scratch" ]]; then echo "creating relevant directory" mkdir -p /home/"$current_user"/Downloads/scratch/"$current_user"/project1/project2 else echo "scratch directory already exists" : fi …