utPLSQL/utPLSQL-cli

CLI behaves differently on linux and windows when passing quoted parameters

pesse opened this issue · 3 comments

pesse commented

A call with the following parameters

-source_path=test/bar/src/main/resources/db/oracle/repeatable/
-regex_expression=".*(\\|\/)((\w+)\.)?(\w+)\.(\w{3})"
-owner_subexpression=3
-name_subexpression=4
-type_subexpression=5
-test_path=test/bar/src/test/resources/db/oracle/repeatable/
-regex_expression=".*(\\|\/)((\w+)\.)?(\w+)\.(\w{3})"
-owner_subexpression=3
-name_subexpression=4
-type_subexpression=5

will result in different build_file_mappings on linux and windows.
Windows: .*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)R__[0-9.]+_(\w+).(\w{3}) (correct)
Linux: ".*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)R__[0-9.]+_(\w+).(\w{3})" (not correct)

Hi,

It's about protecting \\ in windows and linux env from not being interpreted (maybe other special characters are concerned) :

For windows it should be double quotes :
-regex_expression=".*(\\|\/)((\w+)\.)?(\w+)\.(\w{3})"

For linux, it should be simple quote :
-regex_expression='.*(\\|\/)((\w+)\.)?(\w+)\.(\w{3})'

I'm running utplsql with maven-exec-plugin (as utplsql maven plugin is not working).
So the pluggin adds quotes to protect arguments from being interpreted.

The ony workaround i've found is to use a profile section in my pom.xml to set the right regex :

Use a property for the regexp

  <configuration>
	<executable>${poc.utplsql_path}</executable>
	<arguments>
		<argument>run</argument>
		<argument>USR/PWD@${bdd_url}</argument>
		<argument>-p=OWNER1,OWNER2</argument>
		<argument>-source_path=src/main/resources/db/oracle/repeatable/</argument>
		<argument>-regex_expression=${utplsql.regexp}</argument>
		[...]

Set it with depending of the os :

<profiles>
        <profile>
            <id>windows-utplsql</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <utplsql.regexp>".*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)R__[0-9.]+_(\w+).(\w{3})"</utplsql.regexp>
            </properties>
        </profile>
        <profile>
            <id>linux-utplsql</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <utplsql.regexp>.*(\\|\/)(\w+)(\\|\/)(\w+)(\\|\/)R__[0-9.]+_(\w+).(\w{3})</utplsql.regexp>
            </properties>
        </profile>
    </profiles>

which finally allows me to have the "same" command line.

pesse commented

After thinking about it I would see that issue as problem of missing examples rather than as problem of the cli implementation. Because as you said, @jgarec, it has to do with protecting special chars with quotes - and that's something that just works differently on *nix/windows.

I think the underlying problem could also be solved by issue #23 (json config file) which is one of the next things I'd like to put my hands on.