Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.0.3
-
Fix Version/s: JRuby 1.6RC1
-
Component/s: Miscellaneous
-
Labels:None
-
Environment:AS/400 V5R3
-
Number of attachments :6
Description
The AS/400 contain Java environment and a AIX emulation environment. The latter provide sh and ksh but not bash, so the jruby script (and all the others requiring bash) do not work on this system.
Is there any pressing need for requireing bash or would a regression to sh be reasonable?
A proper raw sh implementation should run on every unix box in existance ![]()
-
- diff
- 17/Feb/09 3:17 PM
- 9 kB
- Gregory Seidman
-
- jruby_sh.patch
- 08/Apr/08 4:20 PM
- 2 kB
- Yannick "Pouype" Francois
-
- jruby.gz
- 07/Mar/08 2:09 PM
- 2 kB
- Thorbjørn Ravn Andersen
-
- jruby.sh
- 21/Oct/10 11:55 AM
- 9 kB
- Glauber Ribeiro
-
- me.patch
- 10/Apr/08 12:28 PM
- 2 kB
- Thomas E Enebo
-
- sh_jruby.patch
- 15/Jan/08 5:24 PM
- 1 kB
- Yannick "Pouype" Francois
Issue Links
- is related to
-
JRUBY-2119
Jruby shell script don't work on KSH shell
-
-
JRUBY-3467
bug with *one* extra space on shebang with jruby-1.2rc1
-
Activity
I'm trying to use JRuby (1.0.3) on my OpenBSD Box and OpenBSD use ksh (by default). Then I have this problem too.
I made some change in jruby script to could use jruby
.
See in attachment a patch file (made from trunk January 15th 2008).
This fix could resolve #1671 <http://jira.codehaus.org/browse/JRUBY-1671> (and perhaps other I don't see)
Hope it's could help other, and hope it's work for *nix with bash.
With this change it seems like filename processing breaks in the script:
~/NetBeansProjects/jruby $ bin/jruby test/test_big_decimal.rb Error opening script file: /Users/headius/NetBeansProjects/jruby/tteesstt/tteesstt__bbiigg__ddeecciimmaall..rrb (No such file or directory)
Fix if possible for 1.1. It would be nice to not depend on bash...if possible.
Just for the record: This also applies to bin/jruby in JRuby 1.1RC1
Ping! We're pushing out RC3 soon...if there's way to get sh scripts that will do everything our current bash scripts do, across all platforms, we'd love to include them. But the window is rapidly closing.
Revised bin/jruby which works with Solaris /bin/sh. Cygwin stuff commented out due to insufficient knowledge about what it does.
I have now looked at the jruby command under Solaris, and adapted it to use "expr" and "cut" to do string stuff, and changed the arrays to plain single strings.
The cygwin stuff is commented out, as /bin/sh dislikes the syntax and I do not understand what it does so I will not change it.
I have understood that the "dash" shell is good for weeding out bashisms from shell scripts, but I have not tested it myself.
Let me know if this works for others than me. If not, please run with "sh -xv bin/jruby ...." and attach the output.
Not a 100% patch (either attachment as far as I can tell). Bumping. We can fix in point release.
I'm back again with this SH problem.
I made a new patch for jruby sh script.
I test it under my default Ksh 5.2.14 and for bash 3.2.33.
"Keep It Smart Simple" please. Do not use some bash specific keyword (like "declare" or "
{1:3}").
I hope it will work for everyone.
My modifications which work for regular command-line elements, but fails for things like -e "puts 'heh'"
Poutype, I started with your patch but it had some old stuff in it (like jruby.base) so it was not right. Also it was not quoting properly for certain arguments which have spaces in them. I thought I modified it to my satisfaction, but it is still broken for things like ./bin/jruby -e 'puts "HEH"'. I uploaded this version as a patch so someone can nudge this along. While people are at it they may also want to look at:
Sorry for the delay, but I always have problem with my OpenBSD KSH based machine ! I made a test with latest trunk from svn...
I'm so sad to couldn't use Jruby under my OS. I can't help on other part because of this shell problem :-/
I probably continue to use my own script to launch jruby :-/
Debian's checkbashisms script might help here.
jabley@miq-jabley:~/work/eclipse/jruby/jruby_trunk$ checkbashisms bin/jruby
possible bashism in bin/jruby line 83 (brace expansion):
for j in "$JRUBY_HOME"/lib/
.jar; do
possible bashism in bin/jruby line 129 (declare):
declare -a java_args
possible bashism in bin/jruby line 130 (declare):
declare -a ruby_args
possible bashism in bin/jruby line 136 ($
):
val=$
possible bashism in bin/jruby line 137 ($
{foo:3[:1]}):
if [ "$
" = "-Xmx" ]; then
possible bashism in bin/jruby line 139 ($
):
elif [ "$
" = "-Xss" ]; then
possible bashism in bin/jruby line 150 ($
):
if [ "$
" = "-ea" ]; then
possible bashism in bin/jruby line 153 ($
):
java_args=("$
possible bashism in bin/jruby line 153 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}
" "$
{1:2}")
possible bashism in bin/jruby line 157 (bash arrays, $
-C|-e|-I|-S) ruby_args=("${ruby_args[@]}" "$1" "$2"); shift ;;
possible bashism in bin/jruby line 159 (bash arrays, ${name[0|*|@]}
):
-e*|-I*|-S*) ruby_args=("$
possible bashism in bin/jruby line 163 (bash arrays, ${name[0|*|@]}):
JRUBY_OPTS=("${JRUBY_OPTS[@]}" "-X+C")
possible bashism in bin/jruby line 169 (bash arrays, ${name[0|*|@]}):
JRUBY_OPTS=("${JRUBY_OPTS[@]}" "-X+C")
possible bashism in bin/jruby line 174 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}" "-Dcom.sun.management.jmxremote") ;;
possible bashism in bin/jruby line 177 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}" "-Djava.awt.headless=true") ;;
possible bashism in bin/jruby line 188 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}" "-sourcepath" "$JRUBY_HOME/lib/ruby/1.8:.")
possible bashism in bin/jruby line 189 (bash arrays, ${name[0|*|@]}):
JRUBY_OPTS=("${JRUBY_OPTS[@]}" "-X+C") ;;
possible bashism in bin/jruby line 195 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}" "-Xprof") ;;
possible bashism in bin/jruby line 197 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}" "-Djruby.compat.version=RUBY1_9") ;;
possible bashism in bin/jruby line 199 (bash arrays, ${name[0|*|@]}):
java_args=("${java_args[@]}" "-Djruby.compat.version=RUBY1_8") ;;
possible bashism in bin/jruby line 203 (bash arrays, ${name[0|*|@]}):
-*) ruby_args=("${ruby_args[@]}
" "$1") ;;
possible bashism in bin/jruby line 214 ($
):
JAVA_OPTS="$JAVA_OPTS $JAVA_VM -Djruby.memory.max=$
-Djruby.stack.max=$
{JAVA_STACK:4}"
possible bashism in bin/jruby line 217 (bash arrays, $
ruby_args=("${ruby_args[@]}" "$@")
possible bashism in bin/jruby line 220 (bash arrays, ${name[0|*|@]}
):
set – "$
"
possible bashism in bin/jruby line 246 ($
):
if [[ ( "$
" = "/" ) && ( ( -f "$1" ) || ( -d "$1" )) ]]; then
possible bashism in bin/jruby line 246 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ ( "$
" = "/" ) && ( ( -f "$1" ) || ( -d "$1" )) ]]; then
possible bashism in bin/jruby line 250 (bash arrays, $
set – "${win_args[@]}"
possible bashism in bin/jruby line 259 (bash arrays, ${name[0|*|@]}
):
$JAVA_CMD $PROFILE_ARGS $JAVA_OPTS "$JAVA_JNA" "$JFFI_OPTS" "$
possible bashism in bin/jruby line 276 (bash arrays, ${name[0|*|@]}):
exec "$JAVA_CMD" $JAVA_OPTS "$JAVA_JNA" "$JFFI_OPTS" "${java_args[@]}
" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMETER$CLASSPATH" \
I might get some time to look at this in more detail.
Is this still valid?
I just did the following:
qbproger@linux-3r1v:~/src/jruby> ksh
qbproger@linux-3r1v:/home/qbproger/src/jruby> sad
ksh: sad: not found [No such file or directory]
qbproger@linux-3r1v:/home/qbproger/src/jruby> jruby -e "puts 'hi'"
hi
qbproger@linux-3r1v:/home/qbproger/src/jruby>
ran sad so you could see ksh is running...
We talked this through on IRC and demonstrated that running the "jruby" command does not use the current shell...it force use of bash. There are other complications in testing this as well, since Suse aliases sh to bash in "sh mode", so you need to use dash to get raw sh support. The issue stands, unfortunately ![]()
Here's a patch for bin/jruby that should make it work under standard sh with no bashisms.
Gregory: It's close..for me it seems to be damaging quoted strings passed to e.g. -e:
$ jruby -e "load 'bench/bench_fib_recursive.rb'" -e:1: undefined local variable or method `bench' for main:Object (NameError)
This should work fine, but it's loading the single quotes somehow.
Replaced diff with a new one that does slightly nicer things with quotes. I think one level of quote stripping is unavoidable, however.
Gregory: Looking good so far. I'm going to leave it locally applied for my bug tour this evening, and if it looks good I'll commit it tonight or tomorrow. This will be a long-nagging issue finally resolved.
While you're around, maybe you could look at JRUBY-2900 too? Seems like it's right up your alley ![]()
Ever closer
Now I'm getting a test failure:
[junit] test_java_props_with_spaces(TestLaunchingByShellScript) [test/test_launching_by_shell_script.rb:38]:
[junit] <"a b c"> expected but was
[junit] <"">.
Aren't regression tests great?
I am curious to know whether or not the native launcher solves the problem.
Yeah, the native launcher should in theory solve this problem, assuming that on these fancy systems there is a properly working C++. Granted, there could be compilation failures due to headers and stuff, but we could sort that out.
Just my .02: native launcher is nice, but a working (even 80% working) sh or ksh implementation is much more important, because it would enable JRuby to work or "mostly work" everywhere.
If it's not possible to implement 100% in sh or ksh, please leave the bash implementation as default but include an alternative sh or ksh version of the script. Thank you.
This one has gotten really old again. If someone has a jruby.sh they'd like to contribute that does 90% of what the bash script (and native launcher) can do, we would happily include it. Perhaps that's the one provided by Gregory above?
Glauber: Could you try the provided script and see if it suits your needs? We could even release the sh script as a separate gem (gem install jruby-sh-launcher) so we could spin versions of it more frequently.
Charles, i tried, but that is a diff to be applied to some version of the distribution, i don't know which. It doesn't work with the current distribution. I can attach my own "quick and dirty" sh script. You mentioned a regression test above. Where is that? I could run it before i posted my try.
This is a "brute force" attempt at a Bourne shell script. I simply removed all the Cygwin stuff and changed Bash code that uses arrays so it uses strings instead. Basically, i kept editing it until it didn't crash.
I haven't tested it very much, but it does start JRuby and runs Ruby applications. I'm sure it needs more work.
I'm going to go ahead and commit your jruby.sh and move our bash script to jruby.bash (and fix all references to the latter). At least we'll have something in there, and if you want to try to improve it we can keep incrementally revising it.
Ok, the deed is done. I've added Glauber's script as a first stab at having a jruby.sh. We'll keep the jruby.bash around, since it's still likely more full-featured, but we can incrementally improve jruby.sh now and resolve this bug. If there are additional changes or additions, file a new bug for them.
Thanks for the first draft, Glauber. Feel free to improve it as you have time and we'll incorporate your updates.
commit e0423aac6444ebd93622f3484988553227f7fbcc
Author: Charles Oliver Nutter <headius@headius.com>
Date: Sun Oct 24 12:16:39 2010 -0500
First stab at JRUBY-1967: jruby bash scripts do not work on bash-less unix'es
- Moved bin/jruby.sh to bin/jruby.bash and updated references to it in the build
- Added Bourne shell-compatible bin/jruby.sh from Glauber Ribeiro
:000000 100755 0000000... 9e934d0... A bin/jruby.bash
:100755 100755 47b96ab... a15f654... M bin/jruby.sh
:100644 100644 8a884fc... f61a9db... M build.xml
Is all the cygwin code removed still? I actually use that in windows dev tree (for some reason I don't have native installer in my build tree).
Thomas, i removed all the Cygwin code, because i thought it didn't apply - i thought Cygwin people would run the Bash script. Was this a bad assumption? Also, i'm sure that sh script can use some improvement. I'll take a better look when i have time, but if anyone else would like to do it, i won't fell bad.
I think the ultimate goal should be to just have one shell script which was on sh. A bash-specific one should get removed at some point once the sh one has parity.
Tom: Agreed...for now we can have both, but I would love to see folks continue to bring the sh script into parity with the bash script. Seems like this is something we just have never been able to "big bang" into existence.
Additional work should be done in separate bugs, since this one just required the existence of any sh script. We'll go forward from here.
OK, i'm working on this again... it really shouldn't take much to make this fully work with ksh and possibly sh.
But i don't understand this syntax:
http://glauber.pastebin.com/0xxuC7tF
What does
val=$
and $
{val:0:4}mean?
g
Glauber,
Please read the bash reference manual: http://www.gnu.org/software/bash/manual/bashref.html
In particular, look at http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion
We are very interested in any improvements to our UNIX startup scripts, but we are not sh experts. We started using bash because we could not find a way to make it work with simple sh. If there's a way to do what we do now and go back to sh, we'd include it.