Temporary change dir on bash file
I have a project which has web code and server code, to build the project, I need to build the web module first, then build the server…
I have a project which has web code and server code, to build the project, I need to build the web module first, then build the server code. Because the directory is different, so I need to navigate to the web folder and build, then navigate back to build the server code.
For example, my project has structure like below:
├── build.sh (1)
├── frontend
│ └── web
│ └── build.sh (2)
└── main.go
With the first example, I need call second build.sh in the first build.sh
file, that means in the first build.sh file, I need to temporary change the directory to frontend/web
, then call build.sh
file, then move back to build the server code.
So in the first build.sh
file, I can write code like below:
(cd frontend/web && build.sh)