简体   繁体   中英

Unix: bash script calling script, and relative paths

I have the following directory structure

.
|_build.sh
|_dir
  |_build.sh
  |_Dockerfile

Here is the content of upper level build.sh

#!/bin/bash
./dir/build.sh

and here is the content of bottom level build.sh

#!/bin/bash
docker build -t test .

However, when I run upper level build.sh I get the following error

unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFi
leAttributesEx C:\Dockerfile: The system cannot find the fil
e specified.

How do I preserve the relative path relative to the location of the script being called?

Slightly different approach but might work. This in your top level build.sh:

#!/bin/bash
cd ./dir
docker build -t test .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM