[PATCH v4 1/2] pacman-conf.c: add short options

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH v4 1/2] pacman-conf.c: add short options

Ivy Foster-2
From: Ivy Foster <[hidden email]>

---
 src/pacman/pacman-conf.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 1e6f55f9..ab73d896 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -42,13 +42,13 @@ static void usage(int ret)
  hputs("usage:  pacman-conf [options] [<directive>...]");
  hputs("        pacman-conf (--repo-list|--help|--version)");
  hputs("options:");
- hputs("  --config=<path>  set an alternate configuration file");
- hputs("  --rootdir=<path> set an alternate installation root");
- hputs("  --repo=<remote>  query options for a specific repo");
- hputs("  --verbose        always show directive names");
- hputs("  --repo-list      list configured repositories");
- hputs("  --help           display this help information");
- hputs("  --version        display version information");
+ hputs("  -c, --config=<path>  set an alternate configuration file");
+ hputs("  -R, --rootdir=<path> set an alternate installation root");
+ hputs("  -r, --repo=<remote>  query options for a specific repo");
+ hputs("  -v, --verbose        always show directive names");
+ hputs("  -l, --repo-list      list configured repositories");
+ hputs("  -h, --help           display this help information");
+ hputs("  -V, --version        display version information");
 #undef hputs
  cleanup();
  exit(ret);
@@ -59,7 +59,7 @@ static void parse_opts(int argc, char **argv)
  int c;
  config_file = CONFFILE;
 
- const char *short_opts = "";
+ const char *short_opts = "c:hlR:r:Vv";
  struct option long_opts[] = {
  { "config"    , required_argument , NULL , 'c' },
  { "rootdir"   , required_argument , NULL , 'R' },
--
2.16.1
Reply | Threaded
Open this post in threaded view
|

[PATCH v4 2/2] pacman-conf.c: exit if cannot create config data structure

Ivy Foster-2
From: Ivy Foster <[hidden email]>

---
 src/pacman/pacman-conf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index ab73d896..4ffa24a3 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -400,7 +400,10 @@ int main(int argc, char **argv)
 {
  int ret = 0;
 
- config = config_new();
+ if(!(config = config_new())) {
+ /* config_new prints the appropriate error message */
+ return 1;
+ }
  parse_opts(argc, argv);
  if(!config) {
  ret = 1;
--
2.16.1
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v4 2/2] pacman-conf.c: exit if cannot create config data structure

Andrew Gregory
On 02/15/18 at 04:20pm, [hidden email] wrote:

> From: Ivy Foster <[hidden email]>
>
> ---
>  src/pacman/pacman-conf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
> index ab73d896..4ffa24a3 100644
> --- a/src/pacman/pacman-conf.c
> +++ b/src/pacman/pacman-conf.c
> @@ -400,7 +400,10 @@ int main(int argc, char **argv)
>  {
>   int ret = 0;
>  
> - config = config_new();
> + if(!(config = config_new())) {
> + /* config_new prints the appropriate error message */
> + return 1;
> + }
>   parse_opts(argc, argv);
>   if(!config) {
>   ret = 1;

ACK.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v4 1/2] pacman-conf.c: add short options

Allan McRae
In reply to this post by Ivy Foster-2
On 16/02/18 08:20, [hidden email] wrote:
> From: Ivy Foster <[hidden email]>
>
> ---
>  src/pacman/pacman-conf.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>

Thanks,
A