I've some issue managing path with spaces passed to a function.
a test code
#!/bin/bash
WORKING_DIR="./test"
mkdir -p "$WORKING_DIR/entry-A"
mkdir -p "$WORKING_DIR/entry-B"
mkdir -p "$WORKING_DIR/entry C D E "
checkFolder() {
echo $1
ls $1
}
export -f checkFolder
find $WORKING_DIR -type d -exec bash -c 'checkFolder "$@"' bash {} \;
Here the output:
here the output:
./test.sh
./test
entry-A entry-B 'entry C D E ' 'entry D E '
./test/entry-A
./test/entry-B
./test/entry D E
ls: cannot access './test/entry': No such file or directory
ls: cannot access 'D': No such file or directory
ls: cannot access 'E': No such file or directory
./test/entry C D E
ls: cannot access './test/entry': No such file or directory
ls: cannot access 'C': No such file or directory
ls: cannot access 'D': No such file or directory
ls: cannot access 'E': No such file or directory
Could you suggest me the correct way to proceed in order to manage path with spaces and other special chars in this specific case?
thanks