Fix exit with status code 0 for --help
This commit is contained in:
parent
6b6d49cb6a
commit
cee92b7fdb
@ -1,10 +1,14 @@
|
|||||||
Name: scrub
|
Name: scrub
|
||||||
Version: 2.5.2
|
Version: 2.5.2
|
||||||
Release: 14
|
Release: 15
|
||||||
Summary: A disk overwrite utility
|
Summary: A disk overwrite utility
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: https://github.com/chaos/scrub
|
URL: https://github.com/chaos/scrub
|
||||||
Source0: http://bbgentoo.ilb.ru/distfiles/scrub-2.5.2.tar.bz2
|
Source0: http://bbgentoo.ilb.ru/distfiles/scrub-2.5.2.tar.bz2
|
||||||
|
# https://github.com/chaos/scrub/commit/006fd942abd78d3128d427f1ede9786abe14c65f
|
||||||
|
Patch0: usage-Exit-with-status-code-0-for-help.patch
|
||||||
|
# https://github.com/chaos/scrub/commit/bd88864d8ee15a65d5ecdb3818afa4d5193d2455
|
||||||
|
Patch1: usage-Output-to-stdout-on-exit-code-0.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Scrub writes patterns on files or disk devices to make
|
Scrub writes patterns on files or disk devices to make
|
||||||
@ -32,5 +36,8 @@ retrieving the data more difficult. It operates in one of three modes:
|
|||||||
%{_mandir}/man1/scrub.1*
|
%{_mandir}/man1/scrub.1*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jan 30 2024 yaoxin <yao_xin001@hoperun.com> - 2.5.2-15
|
||||||
|
- Fix exit with status code 0 for --help
|
||||||
|
|
||||||
* Thu Nov 28 2019 Jiangping Hu <hujiangping@huawei.com> - 2.5.2-14
|
* Thu Nov 28 2019 Jiangping Hu <hujiangping@huawei.com> - 2.5.2-14
|
||||||
- Package init
|
- Package init
|
||||||
|
|||||||
51
usage-Exit-with-status-code-0-for-help.patch
Normal file
51
usage-Exit-with-status-code-0-for-help.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 006fd942abd78d3128d427f1ede9786abe14c65f Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
|
||||||
|
Date: Thu, 12 Apr 2018 08:07:29 +0300
|
||||||
|
Subject: [PATCH 1/2] usage: Exit with status code 0 for --help
|
||||||
|
|
||||||
|
---
|
||||||
|
src/scrub.c | 10 ++++++----
|
||||||
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/scrub.c b/src/scrub.c
|
||||||
|
index dec71f3..b2d98e5 100644
|
||||||
|
--- a/src/scrub.c
|
||||||
|
+++ b/src/scrub.c
|
||||||
|
@@ -98,7 +98,7 @@ static struct option longopts[] = {
|
||||||
|
char *prog;
|
||||||
|
|
||||||
|
static void
|
||||||
|
-usage(void)
|
||||||
|
+usage(int rc)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage: %s [OPTIONS] file\n"
|
||||||
|
@@ -119,7 +119,7 @@ usage(void)
|
||||||
|
|
||||||
|
fprintf(stderr, "Available patterns are:\n");
|
||||||
|
seq_list ();
|
||||||
|
- exit(1);
|
||||||
|
+ exit(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -217,12 +217,14 @@ main(int argc, char *argv[])
|
||||||
|
topt = true;
|
||||||
|
break;
|
||||||
|
case 'h': /* --help */
|
||||||
|
+ usage(0);
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
- usage();
|
||||||
|
+ usage(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argc - optind != 1)
|
||||||
|
- usage();
|
||||||
|
+ usage(1);
|
||||||
|
filename = argv[optind];
|
||||||
|
|
||||||
|
if (!seq)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
86
usage-Output-to-stdout-on-exit-code-0.patch
Normal file
86
usage-Output-to-stdout-on-exit-code-0.patch
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
From bd88864d8ee15a65d5ecdb3818afa4d5193d2455 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
|
||||||
|
Date: Thu, 12 Apr 2018 08:39:20 +0300
|
||||||
|
Subject: [PATCH] usage: Output to stdout on exit code 0
|
||||||
|
|
||||||
|
---
|
||||||
|
src/pattern.c | 6 +++---
|
||||||
|
src/pattern.h | 3 ++-
|
||||||
|
src/scrub.c | 7 ++++---
|
||||||
|
3 files changed, 9 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/pattern.c b/src/pattern.c
|
||||||
|
index 9cc258c..9926d84 100644
|
||||||
|
--- a/src/pattern.c
|
||||||
|
+++ b/src/pattern.c
|
||||||
|
@@ -414,7 +414,7 @@ seq2str(const sequence_t *sp, char *buf, int len)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
-seq_list(void)
|
||||||
|
+seq_list(FILE *fp)
|
||||||
|
{
|
||||||
|
const int len = seq_count();
|
||||||
|
char buf[80];
|
||||||
|
@@ -422,10 +422,10 @@ seq_list(void)
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
seq2str(sequences[i], buf, sizeof(buf));
|
||||||
|
- fprintf(stderr, "%s\n", buf);
|
||||||
|
+ fprintf(fp, "%s\n", buf);
|
||||||
|
}
|
||||||
|
seq2str(&custom_seq, buf, sizeof(buf));
|
||||||
|
- fprintf(stderr, "%s\n", buf);
|
||||||
|
+ fprintf(fp, "%s\n", buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff --git a/src/pattern.h b/src/pattern.h
|
||||||
|
index 8b6e7ab..e29a9af 100644
|
||||||
|
--- a/src/pattern.h
|
||||||
|
+++ b/src/pattern.h
|
||||||
|
@@ -23,6 +23,7 @@
|
||||||
|
* with Scrub; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
\*****************************************************************************/
|
||||||
|
+#include <stdio.h>
|
||||||
|
|
||||||
|
#define MAXPATBYTES 16
|
||||||
|
#define MAXSEQPATTERNS 35
|
||||||
|
@@ -45,7 +46,7 @@ typedef struct {
|
||||||
|
} sequence_t;
|
||||||
|
|
||||||
|
const sequence_t *seq_lookup(char *name);
|
||||||
|
-void seq_list(void);
|
||||||
|
+void seq_list(FILE *fp);
|
||||||
|
char *pat2str(pattern_t p);
|
||||||
|
void memset_pat(void *s, pattern_t p, size_t n);
|
||||||
|
|
||||||
|
diff --git a/src/scrub.c b/src/scrub.c
|
||||||
|
index b2d98e5..8c3490f 100644
|
||||||
|
--- a/src/scrub.c
|
||||||
|
+++ b/src/scrub.c
|
||||||
|
@@ -100,7 +100,8 @@ char *prog;
|
||||||
|
static void
|
||||||
|
usage(int rc)
|
||||||
|
{
|
||||||
|
- fprintf(stderr,
|
||||||
|
+ FILE *fp = rc ? stderr : stdout;
|
||||||
|
+ fprintf(fp,
|
||||||
|
"Usage: %s [OPTIONS] file\n"
|
||||||
|
" -v, --version display scrub version and exit\n"
|
||||||
|
" -p, --pattern pat select scrub pattern sequence\n"
|
||||||
|
@@ -117,8 +118,8 @@ usage(int rc)
|
||||||
|
" -h, --help display this help message\n"
|
||||||
|
, prog);
|
||||||
|
|
||||||
|
- fprintf(stderr, "Available patterns are:\n");
|
||||||
|
- seq_list ();
|
||||||
|
+ fprintf(fp, "Available patterns are:\n");
|
||||||
|
+ seq_list (fp);
|
||||||
|
exit(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user