ENT-13025: Switched from ls to find to determine if directory is empty#1734
ENT-13025: Switched from ls to find to determine if directory is empty#1734nickanderson wants to merge 1 commit into
Conversation
Ticket: ENT-13025 Changelog: Fixed case where upgrade is aborted when BACKUP_DIR is empty
7658aa5 to
2cb7b20
Compare
|
Just came across this old pr thats been aproved since june 2025 I see the ticket itself was rejected. @larsewi @craigcomstock do you want this change ? |
| # If the backup directory exists inspect it more closely | ||
| if [ -d "$BACKUP_DIR" ]; then | ||
| # If the backup directory is not empty we don't want to continue. | ||
| if find "$BACKUP_DIR" -maxdepth 1 -mindepth 1 -print -quit | grep -q .; then |
There was a problem hiding this comment.
What is the advantage? I don't see why this is better.
There was a problem hiding this comment.
I agree that find is probably better but it is not more readable. For that I might suggest
if [ "$(du -a "$BACKUP_DIR" | wc -l)" -gt "1" ]; then
du (disk usage) is an old-timer but does make some sense and hopefully is stable. :p
|
Marking this PR as stale due to inactivity; it will be closed in 7 days. |
larsewi
left a comment
There was a problem hiding this comment.
The ls command is known to be unreliable across different implementations. However, in this case it does not really matter, since we are not actually trying to parse the output.
PRO: this would silence a shellcheck warning. CON: slightly less readable.
Ticket: ENT-13025