mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Exit with 1 and a message when -a and -n are both provided
This commit is contained in:
35
atom.sh
35
atom.sh
@@ -26,10 +26,20 @@ esac
|
||||
|
||||
export ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=true
|
||||
|
||||
while getopts ":wtfvh-:" opt; do
|
||||
ATOM_ADD=false
|
||||
ATOM_NEW_WINDOW=false
|
||||
EXIT_CODE_OVERRIDE=
|
||||
|
||||
while getopts ":anwtfvh-:" opt; do
|
||||
case "$opt" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
add)
|
||||
ATOM_ADD=true
|
||||
;;
|
||||
new-window)
|
||||
ATOM_NEW_WINDOW=true
|
||||
;;
|
||||
wait)
|
||||
WAIT=1
|
||||
;;
|
||||
@@ -45,6 +55,12 @@ while getopts ":wtfvh-:" opt; do
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
a)
|
||||
ATOM_ADD=true
|
||||
;;
|
||||
n)
|
||||
ATOM_NEW_WINDOW=true
|
||||
;;
|
||||
w)
|
||||
WAIT=1
|
||||
;;
|
||||
@@ -58,6 +74,11 @@ while getopts ":wtfvh-:" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${ATOM_ADD}" = "true" ] && [ "${ATOM_NEW_WINDOW}" = "true" ]; then
|
||||
EXPECT_OUTPUT=1
|
||||
EXIT_CODE_OVERRIDE=1
|
||||
fi
|
||||
|
||||
if [ $REDIRECT_STDERR ]; then
|
||||
exec 2> /dev/null
|
||||
fi
|
||||
@@ -115,7 +136,11 @@ if [ $OS == 'Mac' ]; then
|
||||
|
||||
if [ $EXPECT_OUTPUT ]; then
|
||||
"$ATOM_PATH/$ATOM_APP_NAME/Contents/MacOS/$ATOM_EXECUTABLE_NAME" --executed-from="$(pwd)" --pid=$$ "$@"
|
||||
exit $?
|
||||
if [ $? -eq 0 ] && [ -n "${EXIT_CODE_OVERRIDE}" ]; then
|
||||
exit "${EXIT_CODE_OVERRIDE}"
|
||||
else
|
||||
exit $?
|
||||
fi
|
||||
else
|
||||
open -a "$ATOM_PATH/$ATOM_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ --path-environment="$PATH" "$@"
|
||||
fi
|
||||
@@ -144,7 +169,11 @@ elif [ $OS == 'Linux' ]; then
|
||||
|
||||
if [ $EXPECT_OUTPUT ]; then
|
||||
"$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@"
|
||||
exit $?
|
||||
if [ $? -eq 0 ] && [ -n "${EXIT_CODE_OVERRIDE}" ]; then
|
||||
exit "${EXIT_CODE_OVERRIDE}"
|
||||
else
|
||||
exit $?
|
||||
fi
|
||||
else
|
||||
(
|
||||
nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$ATOM_HOME/nohup.out" 2>&1
|
||||
|
||||
@@ -105,6 +105,16 @@ module.exports = function parseCommandLine (processArgs) {
|
||||
executedFrom = process.cwd()
|
||||
}
|
||||
|
||||
if (newWindow && addToLastWindow) {
|
||||
process.stderr.write(
|
||||
`Only one of the --add and --new-window options may be specified at the same time.\n\n${options.help()}`,
|
||||
)
|
||||
|
||||
// Exiting the main process with a nonzero exit code on MacOS causes the app open to fail with the mysterious
|
||||
// message "LSOpenURLsWithRole() failed for the application /Applications/Atom Dev.app with error -10810."
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
let pidToKillWhenClosed = null
|
||||
if (args['wait']) {
|
||||
pidToKillWhenClosed = args['pid']
|
||||
|
||||
Reference in New Issue
Block a user