[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #62268] [feature request] -quit N to make find exit immediately wit
From: |
Martin von Wittich |
Subject: |
[bug #62268] [feature request] -quit N to make find exit immediately with a certain exit code |
Date: |
Fri, 8 Apr 2022 09:45:13 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?62268>
Summary: [feature request] -quit N to make find exit
immediately with a certain exit code
Project: findutils
Submitted by: martinvonwittich
Submitted on: Fri 08 Apr 2022 01:45:11 PM UTC
Category: find
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: None
Discussion Lock: Any
Fixed Release: None
_______________________________________________________
Details:
A very typical use case for find in shell scripting is to check if some files
exist, e.g. in an if block:
if find /tmp -name 'some_pattern*' | grep -q .
then
do_something
fi
Unfortunately find currently doesn't have any way to communicate "some
matches" or "no matches" via exit code, necessitating the grep -q workaround,
or another workaround like -exec false:
if find /tmp -name 'some_pattern*' -exec false {} +
then
do_something
fi
There is a -quit operator that exits find immediately, but it doesn't
currently support specifying an exit code. It would be useful if it were
possible to specify an exit code via -quit N so we could use find like this:
if ! find /tmp -name 'some_pattern*' -quit 1
then
do_something
fi
Adding support for specifying an exit code has been suggested by berny before,
but unfortunately it went unnoticed:
https://savannah.gnu.org/bugs/?func=detailitem&item_id=54730#comment6
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62268>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #62268] [feature request] -quit N to make find exit immediately with a certain exit code,
Martin von Wittich <=