Runner behavior changed

runner

#1

I’ve had a custom Java build-and-run script in my workspace for the past ~6 months that has been working just fine. Today, at roughly ~7pm PST, the behavior changed drastically and it was hopelessly broken.

I can’t find any release notes for Cloud9, or anything else that indicated a change. Was this change intentional, or is this a bug?

Runner:

{
    "cmd": ["java", "-classpath", "$OUT_DIR", "$MAIN_CLASS", "$args"],
    "env": {
        "OUT_DIR": "$([ -f .bin ] && rm -r .bin; mkdir -p .bin ; echo .bin)",
        "FILES": "$(find . -path './.c9*' -prune -o -print | grep '.*\\.java' | sed 's:^./::g' | tr '\n' ' ')",
        "MAIN_CLASS": "$(echo $file | sed 's:$project_path::g' | sed 's:.java$::g' | sed 's:/:.:g')",
        "COMPILED_FILES": "$(javac -d $OUT_DIR $FILES)"
    },
    "info": "\\033[01;34mRunning\\033[00m \\033[01;31m$file_name\\033[00m\n",
    "selector": "source.java",
    "working_dir": "$project_path"
}

Running a “HelloWorld.java” program before:

Running HelloWorld.java                                                                                                                                                                             
                                                                                                                                                                                                    
Hello, world!

Running a “HelloWorld.java” program after:

Running HelloWorld.java                                                                                                                                                                             
                                                                                                                                                                                                    
Error: Could not find or load main class $(echo .home.ubuntu.workspace.HelloWorld.java | sed 's:.home.ubuntu.workspace.::g' | sed 's:.java$::g' | sed 's:.:.:g')

#2

Hi,
there was a bug in handling env variables which allowed to execute arbitrary code instead of using them literally.

Please update the runner to use script instead of env

{
    "script": [
        "OUT_DIR=\"$([ -f .bin ] && rm -r .bin; mkdir -p .bin ; echo .bin)\"",
        "FILES=\"$(find . -path './.c9*' -prune -o -print | grep '.*\\.java' | sed 's:^./::g' | tr '\n' ' ')\"",
        "MAIN_CLASS=\"$(echo $file | sed \"s:$project_path::g\" | sed 's:.java$::g' | sed 's:/:.:g')\"",
        "COMPILED_FILES=\"$(javac -d $OUT_DIR $FILES)\"",
        "java -classpath \"$OUT_DIR\" \"$MAIN_CLASS\" \"$args\""
    ],
    "env": {},
    "info": "\\033[01;34mRunning\\033[00m \\033[01;31m$file_name\\033[00m\n",
    "selector": "source.java",
    "working_dir": "$project_path"
}

#3

Awesome – that’s exactly the API I was looking for in the first place!

Thanks for the prompt and super-helpful reply.


#4