Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sh scripts for bash shell #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Execute 'jenv getjava' command and capture its output
var=$(jenv getjava)

# Check if the specified Java executable exists
if [ -x "$var/bin/java" ]; then
# Execute the Java program with provided arguments
"$var/bin/java" "$@"
else
# Print an error message if the specified Java executable does not exist
echo "There was an error:"
echo "$var"
fi
43 changes: 43 additions & 0 deletions jenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Check if PowerShell is in PATH
if ! command -v pwsh &> /dev/null; then
if ! command -v powershell &> /dev/null; then
echo "Neither pwsh.exe nor powershell.exe was found in your PATH."
echo "Please install PowerShell as it is required."
exit 1
else
ps=powershell
fi
else
ps=pwsh
fi

# Execute PowerShell script with required options
"$ps" -executionpolicy remotesigned -File "$(dirname "$0")/src/jenv.ps1" "$@" --output

# Process temporary files
if [ -f jenv.home.tmp ]; then
while IFS= read -r line; do
JAVA_HOME=$line
done < jenv.home.tmp
"C:\Program Files\Git\usr\bin\rm" -f jenv.home.tmp
fi

if [ -f jenv.path.tmp ]; then
while IFS= read -r line; do
PATH=$line
done < jenv.path.tmp
"C:\Program Files\Git\usr\bin\rm" -f jenv.path.tmp
fi

if [ -f jenv.use.tmp ]; then
while IFS= read -r line; do
if [ "$line" == "remove" ]; then
unset JENVUSE
else
JENVUSE=$line
fi
done < jenv.use.tmp
"C:\Program Files\Git\usr\bin\rm" -f jenv.use.tmp
fi