From aff332d58c41084399310e5e9d259777703dd04b Mon Sep 17 00:00:00 2001 From: tilman Date: Thu, 14 Nov 2024 23:33:02 +0100 Subject: [PATCH 1/3] change exit codes --- xdg-desktop-search | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xdg-desktop-search b/xdg-desktop-search index e53eae8..8654a1a 100755 --- a/xdg-desktop-search +++ b/xdg-desktop-search @@ -68,7 +68,7 @@ environment variable `XDG_DATA_DIRS`. ## RETURN VALUES The command returns 0 if .desktop files were found that match the specified -criteria, 1 on usage error and 2 if no matching .desktop files were found. +criteria, 1 if no matching .desktop files were found and 127 on usage error. ## EXAMPLE @@ -139,7 +139,7 @@ parse_options() { -d|--show-directive) [[ $counter -gt $argc ]] && { echo "ERROR: Missing argument for option -d; aborted." >&2 ; - exit 1 ; + exit 127 ; } show_directives+=( "$1" ) shift @@ -148,7 +148,7 @@ parse_options() { -s|--search-directive) [[ $counter -gt $argc ]] && { echo "ERROR: Missing argument for option -s; aborted." >&2 ; - exit 1 ; + exit 127 ; } search_directives+=( "$1" ) shift @@ -209,7 +209,7 @@ done if [[ $found -gt 0 ]] ; then exit 0 else - exit 2 + exit 1 fi # vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab: From 3c51b624e5f97ea70e844c006c830bf4ed2a1eeb Mon Sep 17 00:00:00 2001 From: Tilman Kranz Date: Fri, 30 May 2025 19:37:12 +0200 Subject: [PATCH 2/3] slight manpage formatting corrections --- Makefile | 2 +- README.md | 2 +- xdg-desktop-search.1 | 27 +++++++++++---------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 23b2da4..9e90cf3 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ $(README): $(PROGRAM) ./$(PROGRAM) --help > $(README) $(MANPAGE): $(README) - ronn < $(README) > $(MANPAGE) + ronn --date=$$(date +"%Y-%m-%d") --manual="User Commands" --organization=tk-sls.de/git --section="1" < $(README) > $(MANPAGE) .PHONY: all install install-bin install-doc install-man diff --git a/README.md b/README.md index 847b5d9..41299fe 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ specified by `XDG_DATA_DIRS`. To match, the string "firefox" must be contained in either the "Exec" or the "Comment" directive. List the matching files, also show the "Exec" and "TryExec" directives in each found file. -```shell +``` xdg-desktop-search -s Exec -s Comment -v -d Exec -d TryExec firefox ``` diff --git a/xdg-desktop-search.1 b/xdg-desktop-search.1 index 35b3419..19a6778 100644 --- a/xdg-desktop-search.1 +++ b/xdg-desktop-search.1 @@ -1,12 +1,10 @@ -.\" generated with Ronn-NG/v0.10.1 -.\" http://github.com/apjanke/ronn-ng/tree/0.10.1 -.TH "XDG\-DESKTOP\-SEARCH" "1" "November 2024" "" +.\" generated with Ronn-NG/v0.9.1 +.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 +.TH "XDG\-DESKTOP\-SEARCH" "1" "May 2025" "tk-sls.de/git" "User Commands" .SH "NAME" \fBXDG\-DESKTOP\-SEARCH\fR \- Search for \.desktop files .SH "SYNOPSIS" -.nf -xdg\-desktop\-search [ OPTIONS ] SEARCH \|\.\|\.\|\. -.fi +\fBxdg\-desktop\-search [ OPTIONS ] SEARCH \|\.\|\.\|\.\fR .SH "DESCRIPTION" xdg\-desktop\-search locates files with names that end in \fB\.desktop\fR in sub\-directories of name "applications" of a collection of directories refered to as "XDG data directories"\. It the searches the lines of such desktop files for "directives", meaning key\-value\-assignments such as \fBExec=/some/program\fR where the assigned value matches one of the search string given as commandline arguments SEARCH\. .P @@ -16,28 +14,25 @@ xdg\-desktop\-search returns successfully if the search rendered one or more res .P The path of XDG directories searched can be modified by altering the environment variable \fBXDG_DATA_DIRS\fR\. .SH "ARGUMENTS" -.IP "\(bu" 4 +.IP "\[ci]" 4 \fBSEARCH\fR: Search \.desktop files with search directives containing this string\. The searched directives are "Name" and "Exec" by default but can be overridden using the \fB\-s\fR option (see below)\. .IP "" 0 .SH "OPTIONS" -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-h\fR, \fB\-\-help\fR: Print this message and exit\. -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-v\fR, \fB\-\-verbose\fR: Print directives in found \.desktop files\. -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-d STRING\fR, \fB\-\-show\-directive STRING\fR: Instead of printing all directives when searching in verbose mode, print only the directive given by \fBSTRING\fR (e\.g\. "Name")\. Option can be repeated to print multiple directives\. -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-s STRING\fR, \fB\-\-search\-directive STRING\fR: Instead of searching directives "Name" and "Exec" for strings containing \fBSEARCH\fR, search the given directive instead (e\.g\. "Comment")\. Option can be repeated to search in multiple directives\. .IP "" 0 .SH "RETURN VALUES" The command returns 0 if \.desktop files were found that match the specified criteria, 1 on usage error and 2 if no matching \.desktop files were found\. .SH "EXAMPLE" Search for the string "firefox" in all \.desktop files found in the path specified by \fBXDG_DATA_DIRS\fR\. To match, the string "firefox" must be contained in either the "Exec" or the "Comment" directive\. List the matching files, also show the "Exec" and "TryExec" directives in each found file\. -.IP "" 4 -.nf -xdg\-desktop\-search \-s Exec \-s Comment \-v \-d Exec \-d TryExec firefox -.fi -.IP "" 0 +.P +\fBxdg\-desktop\-search \-s Exec \-s Comment \-v \-d Exec \-d TryExec firefox\fR .SH "AUTHOR AND COPYRIGHT" Copyright \(co 2024 Tilman Kranz \fIt\.kranz@tk\-sls\.de\fR .SH "LICENSE" From a2ddf77d4ea74b0d15037c1f1ac5ea55aef970f8 Mon Sep 17 00:00:00 2001 From: Tilman Kranz Date: Fri, 30 May 2025 19:37:12 +0200 Subject: [PATCH 3/3] slight manpage formatting corrections --- Makefile | 2 +- README.md | 2 +- xdg-desktop-search.1 | 27 +++++++++++---------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 23b2da4..9e90cf3 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ $(README): $(PROGRAM) ./$(PROGRAM) --help > $(README) $(MANPAGE): $(README) - ronn < $(README) > $(MANPAGE) + ronn --date=$$(date +"%Y-%m-%d") --manual="User Commands" --organization=tk-sls.de/git --section="1" < $(README) > $(MANPAGE) .PHONY: all install install-bin install-doc install-man diff --git a/README.md b/README.md index 847b5d9..41299fe 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ specified by `XDG_DATA_DIRS`. To match, the string "firefox" must be contained in either the "Exec" or the "Comment" directive. List the matching files, also show the "Exec" and "TryExec" directives in each found file. -```shell +``` xdg-desktop-search -s Exec -s Comment -v -d Exec -d TryExec firefox ``` diff --git a/xdg-desktop-search.1 b/xdg-desktop-search.1 index 35b3419..19a6778 100644 --- a/xdg-desktop-search.1 +++ b/xdg-desktop-search.1 @@ -1,12 +1,10 @@ -.\" generated with Ronn-NG/v0.10.1 -.\" http://github.com/apjanke/ronn-ng/tree/0.10.1 -.TH "XDG\-DESKTOP\-SEARCH" "1" "November 2024" "" +.\" generated with Ronn-NG/v0.9.1 +.\" http://github.com/apjanke/ronn-ng/tree/0.9.1 +.TH "XDG\-DESKTOP\-SEARCH" "1" "May 2025" "tk-sls.de/git" "User Commands" .SH "NAME" \fBXDG\-DESKTOP\-SEARCH\fR \- Search for \.desktop files .SH "SYNOPSIS" -.nf -xdg\-desktop\-search [ OPTIONS ] SEARCH \|\.\|\.\|\. -.fi +\fBxdg\-desktop\-search [ OPTIONS ] SEARCH \|\.\|\.\|\.\fR .SH "DESCRIPTION" xdg\-desktop\-search locates files with names that end in \fB\.desktop\fR in sub\-directories of name "applications" of a collection of directories refered to as "XDG data directories"\. It the searches the lines of such desktop files for "directives", meaning key\-value\-assignments such as \fBExec=/some/program\fR where the assigned value matches one of the search string given as commandline arguments SEARCH\. .P @@ -16,28 +14,25 @@ xdg\-desktop\-search returns successfully if the search rendered one or more res .P The path of XDG directories searched can be modified by altering the environment variable \fBXDG_DATA_DIRS\fR\. .SH "ARGUMENTS" -.IP "\(bu" 4 +.IP "\[ci]" 4 \fBSEARCH\fR: Search \.desktop files with search directives containing this string\. The searched directives are "Name" and "Exec" by default but can be overridden using the \fB\-s\fR option (see below)\. .IP "" 0 .SH "OPTIONS" -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-h\fR, \fB\-\-help\fR: Print this message and exit\. -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-v\fR, \fB\-\-verbose\fR: Print directives in found \.desktop files\. -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-d STRING\fR, \fB\-\-show\-directive STRING\fR: Instead of printing all directives when searching in verbose mode, print only the directive given by \fBSTRING\fR (e\.g\. "Name")\. Option can be repeated to print multiple directives\. -.IP "\(bu" 4 +.IP "\[ci]" 4 \fB\-s STRING\fR, \fB\-\-search\-directive STRING\fR: Instead of searching directives "Name" and "Exec" for strings containing \fBSEARCH\fR, search the given directive instead (e\.g\. "Comment")\. Option can be repeated to search in multiple directives\. .IP "" 0 .SH "RETURN VALUES" The command returns 0 if \.desktop files were found that match the specified criteria, 1 on usage error and 2 if no matching \.desktop files were found\. .SH "EXAMPLE" Search for the string "firefox" in all \.desktop files found in the path specified by \fBXDG_DATA_DIRS\fR\. To match, the string "firefox" must be contained in either the "Exec" or the "Comment" directive\. List the matching files, also show the "Exec" and "TryExec" directives in each found file\. -.IP "" 4 -.nf -xdg\-desktop\-search \-s Exec \-s Comment \-v \-d Exec \-d TryExec firefox -.fi -.IP "" 0 +.P +\fBxdg\-desktop\-search \-s Exec \-s Comment \-v \-d Exec \-d TryExec firefox\fR .SH "AUTHOR AND COPYRIGHT" Copyright \(co 2024 Tilman Kranz \fIt\.kranz@tk\-sls\.de\fR .SH "LICENSE"