Bug#782559: apt-get complains about unknown options when it's the command that's wrong
Package: apt
Version: 1.1~exp8
Followup-For: Bug #782559
Control: tags -1 patch
This one has annoyed me a few too many times, so I've had a go at a patch.
Best regards,
Carlos
-- Package-specific info:
-- (no /etc/apt/preferences present) --
-- (/etc/apt/sources.list present, but not submitted) --
-- System Information:
Debian Release: stretch/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.0.0-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages apt depends on:
ii adduser 3.113+nmu3
ii debian-archive-keyring 2014.3
ii gnupg 1.4.19-3
ii gnupg2 2.0.28-3
ii libapt-pkg4.15 1.1~exp8
ii libc6 2.19-19
ii libgcc1 1:5.1.1-14
ii libstdc++6 5.1.1-14
apt recommends no packages.
Versions of packages apt suggests:
ii apt-doc 1.1~exp8
ii dpkg-dev 1.18.1
ii python-apt 1.0.0~beta3
ii synaptic 0.81.4
-- no debconf information
>From 0674759ef76eea93a634036b2a0aa2754b164c2d Mon Sep 17 00:00:00 2001
From: Carlos Maddela <maddela@labyrinth.net.au>
Date: Sat, 18 Jul 2015 07:47:09 +1000
Subject: [PATCH] Fix misleading apt-get error message, when invalid operation
given.
Bug: http://bugs.debian.org/782559
---
cmdline/apt-get.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index a285377..cb97193 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1702,7 +1702,12 @@ int main(int argc,const char *argv[]) /*{{{*/
{"help",&ShowHelp},
{0,0}};
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", CommandLine::GetCommand(Cmds, argc, argv));
+ const char *Cmd = CommandLine::GetCommand(Cmds, argc, argv);
+ // If no valid command is found, pass empty string instead so
+ // that parsing for apt-get can still be done.
+ if (Cmd == NULL)
+ Cmd = "";
+ std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", Cmd);
// Set up gettext support
setlocale(LC_ALL,"");
--
2.1.4
Reply to: