Please use ***[code][/code]
*** tags around your code and data, to preserve the original formatting and to improve readability. Do not
use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
I think we need to start by getting a little more info.
First, are you sure you're using bash
? What does the shebang on the top line look like?
If it says #!/bin/sh, then you're using the system's posix-based shell, which may be something like dash instead. That could be why you aren't able to use things like [[..]]
. Always use #!/bin/bash if you want support for bash-specific built ins.
See here for the main differences between bash
and posix shells:
Actually, I see you using things like "bash -x foldertest.sh". That does specify the script as bash, but it's such a sloppy way to do it. As long as the scripts have proper shebangs, just run them directly with "/path/to/foldertest.sh" and similar.
Second, what do the actual
filenames/paths look like? Could you show us an example directory tree and explain more clearly what needs to be tested about it?
The first problem, as UnSpawn mentioned above, is that a globbing pattern of "*/
" will expand into a list of all
subdirectories inside the one specified. So using "/folder/*/folder3/file" could end up giving you:
You can't run a single test on output like that. Perhaps you could capture the results of the glob expansion into an array, then loop over that to test for possible values. But again, it's going to depend on the details of what you have and what you want.
From what's been posted so far, I agree that the whole code flow probably needs re-writing, particularly since you say that it "contains a lot of sensitive data". A script has any kind of data hard-coded into it all (outside of perhaps a few default variable values at the top) is by definition a poorly written script.
I suggest you go through the script to redact (replace with dummy values) the sensitive parts and then post what you can. We need to see more of the code in context before we can really get down to fixing it.
PS: I see a lot of typos in the above posts; 'foder' instead of 'folder', etc. You'll have to tell us whether this is important to the script or just mistakes in explaining it here.