This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Unable to launch project from project directory with spaces in file name | ||
---|---|---|---|
Product: | platform | Reporter: | ahe <ahe> |
Component: | -- Other -- | Assignee: | Jesse Glick <jglick> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | issues, jchalupa |
Priority: | P3 | Keywords: | SPACE_IN_PATH |
Version: | 5.x | ||
Hardware: | PC | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 61551 | ||
Attachments: |
space suppport patch
space suppport patch (a) |
Description
ahe
2005-11-09 12:45:47 UTC
Reassigning to core/modules for evaluation apisupport is fine, as is core/launcher/unix/nbexec (AFAICT). But ide/launcher/unix/netbeans cannot handle spaces in non-userdir params. And I have no idea how to fix it to do so - spent some time trying during the fix of issue #61551 before giving up. If the launcher were written in Perl it would be trivial, but in the Bourne shell this is very hard. The meat of the problem is that although you can pass "$@" along to a child script unchanged, there is no apparent way to examine and replace individual elements of this list without discarding information about the location of argument breaks. Maybe there is some trick with sed or something, but I have no idea how to verify that every Unixish platform we deploy to would have a version installed which is compatible with whatever args it is given. Wrapper-quoting all parameters in ide/launcher/unix/netbeans could help. But also need to hack a little core/launcher/unix/nbexec to strip redundant quotes when it is appropriate to make it work with the case command. I'm not able to explain :) Better to see the attached patch which seems to work somehow. Using very simple sed - so shouldn't be the problem on other platforms. Not sure how much 'remembering' is supported. Could be workarounded by double call to sed eventually. Created attachment 26805 [details]
space suppport patch
There is a little bug. Attaching fixed version.... Created attachment 26806 [details]
space suppport patch (a)
The proposed fix is at best brittle. It would be better if you didn't try to filter out the --userdir option in /cvs/ide/launcher/unix/netbeans,v. In that case, setting userdir can be written like this: userdir="${netbeans_default_userdir}" founduserdir="" for opt in "$@" ; do if [ "${founduserdir}" ] ; then userdir="$opt" break elif [ "$opt" == "--userdir" ] ; then founduserdir="yes" esac done Then later launch nbexec like this: launchNbexec() { if [ "${founduserdir}" ] ; then exec "$nbexec" \ "$@" else sh "$nbexec" \ --userdir "${userdir}" \ "$@" fi } launchNbexec \ --jdkhome "$netbeans_jdkhome" \ --branding nb \ --clusters "$netbeans_clusters" \ --userdir "${userdir}" \ -J-Dnetbeans.importclass=org.netbeans.upgrade.AutoUpgrade \ -J-Dnetbeans.accept_license_class=org.netbeans.license.AcceptLicense \ ${netbeans_default_options} \ "$@" I forgot to remove --userdir from the argument list to launchNbexec: launchNbexec \ --jdkhome "$netbeans_jdkhome" \ --branding nb \ --clusters "$netbeans_clusters" \ -J-Dnetbeans.importclass=org.netbeans.upgrade.AutoUpgrade \ -J-Dnetbeans.accept_license_class=org.netbeans.license.AcceptLicense \ ${netbeans_default_options} \ "$@" 'ide' -> 'core' I much prefer Peter's approach. Should also be applied to apisupport/harness/release/launchers/app.sh. Unfortunately we cannot use it in nbexec, which still hacks around spaces by inserting and then later stripping " chars, since nbexec needs to remove some args (like --cp or -J*) before passing on to the Java launcher. However it could help with the bug reported here. Someone would also need to retest all the scenarios in #61551 with such a change to make sure nothing regressed. Will do for 5.0 if I can find the time, but in the meantime users are well advised to avoid spaces in directory names generally. Ummm. Still not sure in which scenario the second patch wouldn't work - other thing is that it is not as elegant ;) (wrapping all parameters). I would have to try it. The main culprit is nbexec anyway which must count with both, non-quote and quote parameters, since it could be called from another scripts or command line in more ways. Otherwise org.netbeans.Main could complain somehow (don't remember how exactly) because some parameter will not be noticed (effectivelly ignored) in nbexec case command. There are surely more ways. Very sensitive part. Something should be intergratet soon or better for post-5.0 probably. "nbexec [...] must count with both, non-quote and quote parameters, since it could be called from another scripts or command line in more ways" - I don't think so. The convention for Unix executables (unlike Windows) is that char **argv should be exactly what it seems (only 0x00 is really forbidden); if the caller is a shell script then it is the caller's responsibility to quote any args containing spaces... and *not* to include quote characters themselves in args unless you really wanted them: nbexec --reload "/tmp/Jesse's module" ^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ [0] [1] [2] Perhaps you should consider using a small C launcher. We would rather not have to maintain binaries for every Unixish platform: Linux x86, Solaris SPARC, Mac OS X, Solaris x86, Linux x86_64, HPUX, Irix, AIX, .... Every minor launcher source change would require recompilation for every possible platform, which would be a huge headache for us. It's bad enough to have to recompile the Windows launcher, but at least there are plenty of people around who run Windows and can check in a new .exe to CVS occasionally. As I mentioned, Perl would make an ideal launcher language - low overhead, (pseudo-)interpreted, thorough OS integration, etc. - but I think we cannot rely on all of our users having Perl installed. Almost certainly every Linux user will, but I do not know about other Unixish systems. > re quotes vs. non-quotes.
Yes, right. Note that the sed regexp strips only beginning *and* ending quote.
Shouldn't hurt in allmost all cases. Happy bashing :)
Applying a minor variant of Peter's fix. committed Up-To-Date 1.28 ide/launcher/unix/netbeans |