I'm trying to automate my test runner better. For that I need the update file name in a variable. As this name depends on a the version I'm trying to use a find with a pattern to get the file name. That works just fine in bash.
However if I use that same pattern in expect find complains that it can't find anything.
My guess is that expect is doing something to my wildcards. However my experiments with {}
, ""
, ''
or \
didn't result in it working.
I guess I could create a helper sh script to write it into a file and then read that file but I don't like that solution and there has to be an option to pass characters with special tcl meaning as arguments.
At the moment my call looks something like this with an absolute path in front of the pattern:
set pattern {[0-9]*/*test*}
set updateFile [exec find ${pattern} -type f]
The result is that find reports '[0-9]*/*test*': No such file or directory
. The pattern is what I would expect and when I call find [0-9]*/*test* -type f
in bash it results in the expected file path. Find also works fine as long as I don't have any wild cards.
Has anybody an idea what is wrong?
When you run find [0-9]*/*test* -type f
in Bash, it's Bash who interprets the wildcard [0-9]*/*test*
and expand it to multiple files. And then Bash would pass the expanded multiple files to find
. That's to say find
never sees the wildcard.
For exec find $pattern -type f
, Tcl would not interpret what's in $pattern
and pass it directly to find
. Unfortunately find
also does not interpret the wildcards here so it fails with error like find : '[0-9]*/*test*': No such file or directory
.
To work around, you can invoke find
with bash -c
:
exec bash -c "find $pattern -type f"