Bug 273180 - bectl: Add a -q option for mount
Summary: bectl: Add a -q option for mount
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-17 15:03 UTC by Alan Somers
Modified: 2023-12-01 16:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2023-08-17 15:03:02 UTC
It sure would be helpful if "bectl mount" had a -q --quiet option.  When using this option, a successful mount would print only the mountpoint used, and nothing else.  For example, instead of:

$ sudo bectl mount 13.2-RELEASE
Successfully mounted 13.2-RELEASE at /tmp/be_mount.PAGF

it would instead print

$ sudo bectl mount -q 13.2-RELEASE
/tmp/be_mount.PAGF

With such an option, one could more easily use bectl in scripts, like this:

RELEASE=13.2-RELEASE
sudo bectl create ${RELEASE}
BASEDIR=`sudo bectl mount -q ${RELEASE}`
Comment 1 Robert Wing freebsd_committer freebsd_triage 2023-08-17 17:00:14 UTC
I wonder if it'd be ok to just change the message..? instead of adding an additional flag.

Either way, I agree this.

what behavior do you expect when there's a failure?
Comment 2 Alan Somers freebsd_committer freebsd_triage 2023-08-17 17:10:56 UTC
(In reply to Robert Wing from comment #1)
Not sure, because I've never seen a failure from that command before.  I guess it would be find to output nothing to stdout, error message to stderr, and exit 1?
Comment 3 Robert Wing freebsd_committer freebsd_triage 2023-08-23 08:49:55 UTC
(In reply to Alan Somers from comment #2)

https://reviews.freebsd.org/D41562
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-08-23 18:48:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=760987ecd39b54374aef40783b2c232997f3ac04

commit 760987ecd39b54374aef40783b2c232997f3ac04
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2023-08-23 18:39:13 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2023-08-23 18:45:01 +0000

    bectl: make mount subcommand less verbose

    The mount subcommand currently produces output such as:
        # bectl mount <bootenv>
        Successfully mounted <bootenv> at <mountpoint>

    This commit changes it to only print the mountpoint:
        # bectl mount <bootenv>
        <mountpoint>

    This makes it easier to script the mount subcommand. If an error occurs
    while mounting, an error message is printed to stderr and bectl will
    exit with a non-zero value.

    PR:             273180
    Reviewed by:    kevans, asomers
    Differential Revision:  https://reviews.freebsd.org/D41562

 sbin/bectl/bectl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)