There are tons of example out there that show how to loop over directories in a directory with bash. However, I encounter the problem, that the root directory, which is retrieved from a variable, is obviously not resolved correctly.
The idea is to symlink folders from a "package" root folder to "public/typo3conf/ext". This is the folder structure:
project-root
- packages -- project_1 -- project_2
- public -- typo3conf ---ext
The "packages" folder is defined in a yaml file under the "PACKAGES" var and also defined as a fallback option. Another variable, "DOCROOT", points to the "public" folder.
The bash script I use looks like this:
for ext in "${PACKAGES:-packages}/*"; do
pwd # <- just to insure we are on the right level
echo "$ext" # <- this result in "packages/*"
if [ -d "${ext}" ] && [ ! -d "${DOCROOT}/typo3conf/ext/${ext##*/}" ]; then
echo -e " $ext -> ${DOCROOT}/typo3conf/ext/${ext##/}"
ln -frs "$ext" "${DOCROOT}/typo3conf/ext/${ext##/}"
fi
done
This does not work, though: the "ext" variable resolves to "packages/*".
What am I doing wrong?
*
doesn't expand inside double quotes - see for example Wildcards inside quotes – steeldriver Oct 14 '21 at 23:05*/
. – pLumo Oct 15 '21 at 06:45