[gjs/gnome-3-32] console: Don't accept --profile after the script name
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-32] console: Don't accept --profile after the script name
- Date: Tue, 7 May 2019 23:55:13 +0000 (UTC)
commit ae53e6898ad33310fc9e5e3659ad2fee236d5f02
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Apr 13 11:42:50 2019 -0700
console: Don't accept --profile after the script name
This was only intended for arguments that were previously accepted after
the script name on the command line. For example, in some previous
versions,
gjs myapp.js -C myfiles
would pass the -C argument to GJS and hide it from myapp.js. We changed
this some time ago, but kept the behaviour for these arguments while
logging a warning.
However, new arguments should not get this behaviour. I accidentally
implemented it for --profile. Technically it's not backwards compatible
to remove it now, but I think it's OK because nobody would ever have
been able to write
gjs myapp.js --profile myapp.syscap
without getting a warning stating that they shouldn't do that.
gjs/console.cpp | 20 +++-----------------
installed-tests/scripts/testCommandLine.sh | 3 ---
2 files changed, 3 insertions(+), 20 deletions(-)
---
diff --git a/gjs/console.cpp b/gjs/console.cpp
index a110bf31..eb92c06e 100644
--- a/gjs/console.cpp
+++ b/gjs/console.cpp
@@ -42,7 +42,6 @@ static bool enable_profiler = false;
static gboolean parse_profile_arg(const char *, const char *, void *, GError **);
-/* Keep in sync with entries in check_script_args_for_stray_gjs_args() */
// clang-format off
static GOptionEntry entries[] = {
{ "version", 0, 0, G_OPTION_ARG_NONE, &print_version, "Print GJS version and exit" },
@@ -115,19 +114,6 @@ parse_profile_arg(const char *option_name,
return true;
}
-static gboolean
-check_stray_profile_arg(const char *option_name,
- const char *value,
- void *data,
- GError **error_out)
-{
- g_warning("You used the --profile option after the script on the GJS "
- "command line. Support for this will be removed in a future "
- "version. Place the option before the script or use the "
- "GJS_ENABLE_PROFILER environment variable.");
- return parse_profile_arg(option_name, value, data, error_out);
-}
-
static void
check_script_args_for_stray_gjs_args(int argc,
char * const *argv)
@@ -136,13 +122,13 @@ check_script_args_for_stray_gjs_args(int argc,
char **new_coverage_prefixes = NULL;
char *new_coverage_output_path = NULL;
char **new_include_paths = NULL;
- /* Keep in sync with entries[] at the top */
+ // Don't add new entries here. This is only for arguments that were
+ // previously accepted after the script name on the command line, for
+ // backwards compatibility.
static GOptionEntry script_check_entries[] = {
{ "coverage-prefix", 'C', 0, G_OPTION_ARG_STRING_ARRAY, &new_coverage_prefixes },
{ "coverage-output", 0, 0, G_OPTION_ARG_STRING, &new_coverage_output_path },
{ "include-path", 'I', 0, G_OPTION_ARG_STRING_ARRAY, &new_include_paths },
- { "profile", 0, G_OPTION_FLAG_OPTIONAL_ARG | G_OPTION_FLAG_FILENAME,
- G_OPTION_ARG_CALLBACK, reinterpret_cast<void *>(&check_stray_profile_arg) },
{ NULL }
};
char **argv_copy = g_new(char *, argc + 2);
diff --git a/installed-tests/scripts/testCommandLine.sh b/installed-tests/scripts/testCommandLine.sh
index f6ab5d9c..aefe0edc 100755
--- a/installed-tests/scripts/testCommandLine.sh
+++ b/installed-tests/scripts/testCommandLine.sh
@@ -155,9 +155,6 @@ report "--coverage-prefix after script should succeed but give a warning"
$gjs -c 'imports.system.exit(0)' --coverage-prefix=foo --coverage-output=foo 2>&1 | grep -q
'Gjs-WARNING.*--coverage-output'
report "--coverage-output after script should succeed but give a warning"
rm -f foo/coverage.lcov
-$gjs -c 'imports.system.exit(0)' --profile=foo 2>&1 | grep -q 'Gjs-WARNING.*--profile'
-report "--profile after script should succeed but give a warning"
-rm -rf foo
for version_arg in --version --jsversion; do
# --version and --jsversion work
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]