Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 22942 ]] Ensure the shellcommand defaults to COMSPEC on Windows #7454

Merged
merged 1 commit into from Oct 19, 2020

Conversation

livecodepanos
Copy link
Contributor

Goes together with livecode/livecode-ide#2145

@livecodepanos livecodepanos added this to the 9.6.2-rc-1 milestone Oct 15, 2020
Copy link
Contributor

@runrevmark runrevmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this patch there is the possibility that the shellCommand could be empty. There is no way to correctly guess what to use if COMSPEC is empty so we should make sure that shell() does not work if it is (indeed, this would be sensible on all platforms!)

In MCFilesEvalShell after the secureMode check do:

if (MCStringIsEmpty(MCshellcmd))
{
    MCeerror->add(EE_SHELL_BADCOMMAND, 0, 0, "no shell");
    ctxt . Throw();
    return;
}

This will cause an error to be thrown if the shellCommand is empty - rather than it trying to run launch a process with a malformed command line (which will probably fail anyway, but this stops the attempt!).

@@ -1534,8 +1534,8 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
}
}

// On NT systems 'cmd.exe' is the command processor
MCValueAssign(MCshellcmd, MCSTR("cmd.exe"));
// On NT systems use the env var COMSPEC (= C:\Windows\System32\cmd.exe)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/* Default the shellCommand to the value of the COMSPEC environment
 * variable. */

// On NT systems 'cmd.exe' is the command processor
MCValueAssign(MCshellcmd, MCSTR("cmd.exe"));
// On NT systems use the env var COMSPEC (= C:\Windows\System32\cmd.exe)
MCS_getenv(MCSTR("COMSPEC"), MCshellcmd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should use MCValueAssign here like elsewhere:

MCAutoStringRef t_comspec;
if (MCS_getenv(MCSTR("COMSPEC"), &t_comspec))
{
    MCValueAssign(MCshellcmd, *t_comspec);
}
else
{
    MCValueAssign(MCshellcmd, kMCEmptyString);
}

@@ -22,8 +22,8 @@ set the shellCommand to "/bin/sh/ksh"
Value:
The <shellCommand> is a string.
By default, the <shellCommand> <property> is set to "/bin/sh" (the
Bourne shell) on <Unix|Unix systems>, and "command.com" on Windows
systems.
Bourne shell) on <Unix|Unix systems>, and to the environment variable "COMSPEC" on Windows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and to the value of the COMSPEC environment variable on Windows systems.

(I don't think there's a need to say anymore than that).

Should Windows be referred to like <Windows|Windows systems> as it is for Unix?

@@ -0,0 +1 @@
# Ensure the shellcommand defaults to COMSPEC on Windows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shellCommand

@runrevmark
Copy link
Contributor

@livecode-vulcan review ok d8cb11f

@livecode-vulcan
Copy link
Contributor

💙 review by @runrevmark ok d8cb11f

livecode-vulcan added a commit that referenced this pull request Oct 19, 2020
[[ Bug 22942 ]] Ensure the shellcommand defaults to COMSPEC on Windows

Goes together with livecode/livecode-ide#2145
@livecode-vulcan
Copy link
Contributor

😎 test success d8cb11f

  • try-community-armv6-android-sdk26_ndk16r15: success
  • try-community-armv7-android-ndk16r15: success
  • try-community-arm64-android-ndk16r15: success
  • try-community-x86-android-ndk16r15: success
  • try-community-x86_64-android-ndk16r15: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos14.0: success
  • try-community-universal-ios-iphoneos13.5: success
  • try-community-universal-ios-iphonesimulator14.0: success
  • try-community-universal-ios-iphonesimulator13.5: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@livecodepanos livecodepanos merged commit 9bd23b2 into livecode:develop-9.6 Oct 19, 2020
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants