From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 420d33a4 for ; Tue, 18 Feb 2020 10:45:46 +0000 (UTC) Received: (qmail 14413 invoked by alias); 18 Feb 2020 10:45:37 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45455 Received: (qmail 8673 invoked by uid 1010); 18 Feb 2020 10:45:37 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25725. spamassassin: 3.4.2. Clear:RC:0(66.111.4.29):SA:0(-2.6/5.0):. Processed in 3.889815 secs); 18 Feb 2020 10:45:37 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrjeekgddvtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfgjfhfogggtgfesthhqtd dtredtjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgv lhdrshhhrghhrghfrdhnrghmvgeqnecukfhppeejledrudejkedrjedrudekleenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Date: Tue, 18 Feb 2020 10:44:51 +0000 From: Daniel Shahaf To: Zsh Hackers' List Subject: Re: PATCH: sshfs user-side automount Message-ID: <20200218104451.1813845b@tarpaulin.shahaf.local2> In-Reply-To: <1581954328.4418.19.camel@samsung.com> References: <1581954328.4418.19.camel@samsung.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Peter Stephenson wrote on Mon, 17 Feb 2020 15:45 +0000: > This certainly won't go in until the dust has settled, both on the > release and the proposed change, Why don't you push it to the 5.9 branch, then? That's what it's for. > +++ b/Doc/Zsh/contrib.yo > @@ -386,6 +386,7 @@ findex(_cdr) > =C2=A0findex(chpwd_recent_add) (The character on the first column is a non-breaking space, so the diff couldn't easily be applied.) > --- /dev/null > +++ b/Functions/Chpwd/chpwd_check_mount > @@ -0,0 +1,107 @@ > +# Return 0 if the path is available, possibly after mounting, 1 if > +# it is still not available at the end of the function. =E2=8B=AE > +# The return status is 0 if the path exists; 1 if it does not exist > +# (even if a mount was made in an attempt to provide it); 2 if some > +# condition other than a missing directory was found, in particular > +# bad zstyle configuration or an sshfs failure. The return status is documented in two different places. > +# If the argument to the function is a path that doesn't exist, the > +# system checks to see if the path is under /local/dir.=C2=A0=C2=A0If, s= o the > +# other element of the pair is examined.=C2=A0=C2=A0If "method" is a kno= wn method > +# for moutning the remote path path-to-dir the path, it is mounted and Typo "moutning" > + > +# We'll allow the path to be something other than a directory as we > +# are in any case going to check prefixes. > +if [[ -e $1 ]]; then > +=C2=A0=C2=A0if [[ -d $1 ]]; then This does two stat()s in a row on what might be a subdirectory of an sshfs mount. If optimization is a concern, there might be a speed gain from rearranging the code to =C2=ABif [[ -d $1 ]]; =E2=80=A6 elif [[ -e $1 = ]]; =E2=80=A6 fi=C2=BB, or possibly even to use zstat here. > +=C2=A0=C2=A0=C2=A0=C2=A0# As this may be the mount point itself, we'll a= ssume it > +=C2=A0=C2=A0=C2=A0=C2=A0# should be non-empty, though we don't know for = sure. > +=C2=A0=C2=A0=C2=A0=C2=A0local -a files > +=C2=A0=C2=A0=C2=A0=C2=A0files=3D($1/*(DN)) > +=C2=A0=C2=A0=C2=A0=C2=A0(( ${#files} )) && return 0 Suggest to add the =C2=ABY1=C2=BB glob qualifier, or to use the =C2=ABF=C2= =BB glob qualifier. Suggest to directly check whether $1 is a mountpoint. On my system there's a mountpoint(1) utility that can be used as =C2=ABif mountpoint -q /home; then=C2=BB, but it might be unportable. For portability I guess we could use =C2=ABzstat +device=C2=BB. > +=C2=A0=C2=A0else > +=C2=A0=C2=A0=C2=A0=C2=A0# Not a directory, so assume everything is OK. > +=C2=A0=C2=A0=C2=A0=C2=A0return 0 > +=C2=A0=C2=A0fi > +fi > +for locdir remote in $mpath; do > +=C2=A0=C2=A0# To be clever here we would look for the shortest matching = path > +=C2=A0=C2=A0# and work our way down. > +=C2=A0=C2=A0if [[ $dir =3D ${locdir%%:*}(|/*) ]]; then > +=C2=A0=C2=A0=C2=A0=C2=A0mpoint=3D${locdir#*:} > +=C2=A0=C2=A0=C2=A0=C2=A0case $remote in > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0((#b)sshfs:(*)) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if ! sshfs -o workaround=3Drename $m= atch[1] $mpoint; then Quote $match[1] to prevent null elision. Cheers, Daniel