About sh,. bat and binary files?

I'm not an expert like programming.


Found script with the following content:

#!/bin/bash

function die() {
 echo "$1"
 exit 1
}

# Taken from Debian Developers Reference Chapter 6
function pathfind() {
OLDIFS="$IFS"
IFS=:
 for p in $PATH; do
 if [ -x "$p/$*" ]; then
IFS="$OLDIFS"
 return 0
fi
done
IFS="$OLDIFS"
 return 1
}

pathfind "java" || die "[ERROR] could not find: java in \$PATH"

exec java-jar $0 "$@"


PK.... there is 200KB of binary data are simply copied into the script that are not inserted into field of the browser.



Ie then called java, which is passed to the JAR file. In fact, you need to pass the path to the file. As I understand it, this way bash allows you to transfer the contents of the file instead of the path.


Correct me please and explain on the fingers of logic, but also tell me how to do like to Win.
October 8th 19 at 03:13
3 answers
October 8th 19 at 03:15
Solution
Thank you all. Under Windows at random turned out to be this:

@echo off java-jar %0 %* & exit /b 0 ... and then the push binary
October 8th 19 at 03:17
In fact, this script is designed to make Java application *.jar to turn it into an executable UNIX file.
Those binary data at the end of PK... and so is the JAR, ie Java classes in ZIP files.
Logic here is simple; the script looks for the list of paths in the PATH variable to the java program and if it finds — runs, passing the name of the name of the current script as parameters — the parameters with which the script has been launched. If java is not found reports about it.
Do not tell me, why not write just which java? Because of the portability? - kayla.Rowe26 commented on October 8th 19 at 03:20
October 8th 19 at 03:19
Under Windows the way:

@start java %0 %*

Find more questions by tags cmd/batPowerShellbash