Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

Bad substitution from utils/get-value.sh invokation in Makefile (Ubuntu Linux) #10

Open
turbomam opened this issue Apr 12, 2022 · 2 comments

Comments

@turbomam
Copy link
Collaborator

When running make setup

After successful mkdir -p src/mam-lpt1/datamodel:

./utils/get-value.sh: 4: Bad substitution
./utils/get-value.sh: 4: Bad substitution

Research into utils/get-value.sh

#!/bin/sh
# get the value of a key in the about.yaml file
# https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash
grep $1 about.yaml | sed "s/$1:[[:space:]]//" ; test ${PIPESTATUS[0]} -eq 0

Invoked in Makefile as

SCHEMA_NAME = $(shell sh ./utils/get-value.sh name)
SOURCE_SCHEMA_PATH = $(shell sh ./utils/get-value.sh source_schema_path)

Those commands do run for me in isolation, as long as I source them

. ./utils/get-value.sh name

mam-lpt1

. ./utils/get-value.sh source_schema_path

src/linkml/mam_lpt1.yaml

but not if I treat ./utils/get-value.sh like an executable

./utils/get-value.sh name

bash: ./utils/get-value.sh: Permission denied

@matentzn
Copy link

chmod +x ./utils/get-value.sh? Probably you need to check in the file with "executable" flag..

We used to circumvent by using sh ./utils/get-value.sh for all scripts.

@bpow
Copy link
Contributor

bpow commented Apr 20, 2022

This happens because sh and /bin/sh in Ubuntu (and Debian) are dash rather than bash. $PIPESTATUS is bash-specific, so the script (and the Makefile that calls it) should specific bash when bash is needed. #16 would address this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants