• Re: correct escaping or etc for `--head--'

    From Janis Papanagnou@21:1/5 to hput on Sat Apr 16 00:26:28 2022
    On 16.04.2022 00:17, hput wrote:
    Running: Ubuntu 20.04 linux with bash

    Some how I've managed to get a directory written with the name
    `--head--'. Haven't been able to figure out how this got written.

    It appears amongst a short list of other directories that are the
    names of zfs snapshots.

    The `--head--' critter is a directory with files and subdiretories in it. Or at
    least that is how emacs sees it.

    I want to see it with a simple `ls' or `ls -l' command. A few of what
    I've tried:

    are:
    ls

    '--head--'

    \-\-head\-\-

    [\-][\-]head[\-][\-]

    That has drained my obviously less than skillful guesses.


    showing the naming mistake in place:

    cd /rhosts/.zfs/snapshot
    ls -l
    drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_daily drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_monthly drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_weekly drwxrwxrwx 1 root root 0 Apr 15 17:34 --head--


    Can anyone offer something that actually works?


    It's nothing to do with escaping. The tools called with such arguments considers it an option. To prevent that use the end-of-option marker as
    in

    ls -- --head--
    rmdir -- --head--

    etc.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hput@21:1/5 to All on Fri Apr 15 18:17:17 2022
    Running: Ubuntu 20.04 linux with bash

    Some how I've managed to get a directory written with the name
    `--head--'. Haven't been able to figure out how this got written.

    It appears amongst a short list of other directories that are the
    names of zfs snapshots.

    The `--head--' critter is a directory with files and subdiretories in it. Or at
    least that is how emacs sees it.

    I want to see it with a simple `ls' or `ls -l' command. A few of what
    I've tried:

    are:
    ls

    '--head--'

    \-\-head\-\-

    [\-][\-]head[\-][\-]

    That has drained my obviously less than skillful guesses.


    showing the naming mistake in place:

    cd /rhosts/.zfs/snapshot
    ls -l
    drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_daily drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_monthly drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_weekly drwxrwxrwx 1 root root 0 Apr 15 17:34 --head--


    Can anyone offer something that actually works?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Janis Papanagnou on Fri Apr 15 22:41:55 2022
    On Sat, 16 Apr 2022 00:26:28 +0200, Janis Papanagnou wrote:

    On 16.04.2022 00:17, hput wrote:
    Running: Ubuntu 20.04 linux with bash

    Some how I've managed to get a directory written with the name
    `--head--'. Haven't been able to figure out how this got written.

    It appears amongst a short list of other directories that are the
    names of zfs snapshots.

    The `--head--' critter is a directory with files and subdiretories in it. Or at
    least that is how emacs sees it.

    I want to see it with a simple `ls' or `ls -l' command. A few of what
    I've tried:

    are:
    ls

    '--head--'

    \-\-head\-\-

    [\-][\-]head[\-][\-]

    That has drained my obviously less than skillful guesses.


    showing the naming mistake in place:

    cd /rhosts/.zfs/snapshot
    ls -l
    drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_daily
    drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_monthly >> drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_weekly
    drwxrwxrwx 1 root root 0 Apr 15 17:34 --head--


    Can anyone offer something that actually works?


    It's nothing to do with escaping. The tools called with such arguments considers it an option. To prevent that use the end-of-option marker as
    in

    ls -- --head--
    rmdir -- --head--

    alternately...
    ls ./--head--
    rmdir ./--head--



    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to hput on Fri Apr 15 15:42:08 2022
    hput <hputn3@zohomail.com> writes:
    Running: Ubuntu 20.04 linux with bash

    Some how I've managed to get a directory written with the name
    `--head--'. Haven't been able to figure out how this got written.

    It appears amongst a short list of other directories that are the
    names of zfs snapshots.

    The `--head--' critter is a directory with files and subdiretories in it. Or at
    least that is how emacs sees it.

    I want to see it with a simple `ls' or `ls -l' command. A few of what
    I've tried:

    are:
    ls

    '--head--'

    \-\-head\-\-

    [\-][\-]head[\-][\-]

    That has drained my obviously less than skillful guesses.


    showing the naming mistake in place:

    cd /rhosts/.zfs/snapshot
    ls -l
    drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_daily drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_monthly drwxrwxrwx 1 root root 0 Apr 15 17:34 autosnap_2022-04-14_15:55:20_weekly drwxrwxrwx 1 root root 0 Apr 15 17:34 --head--


    Can anyone offer something that actually works?

    Others have suggested "ls -- --head--".

    Another option is "ls ./--head--".

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    Working, but not speaking, for Philips
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David W. Hodgins@21:1/5 to hput on Fri Apr 15 18:29:54 2022
    On Fri, 15 Apr 2022 18:17:17 -0400, hput <hputn3@zohomail.com> wrote:
    I want to see it with a simple `ls' or `ls -l' command. A few of what
    I've tried:

    $ tree -ifa
    .
    ./--head--
    ./--head--/somefile
    1 directory, 1 file

    $ ls -l -- --head--
    total 0
    -rw-r--r-- 1 dave dave 0 Apr 15 18:24 somefile

    I created the directory and file with ...
    $ mkdir -- --head--
    $ touch -- --head--/somefile

    The "-- " indicates what follows is not to be parsed as an option.

    Regards, Dave Hodgins

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Waitzmann@21:1/5 to All on Sat Apr 16 06:53:40 2022
    hput <hputn3@zohomail.com>:
    Running: Ubuntu 20.04 linux with bash


    Some how I've managed to get a directory written with the name
    `--head--'. Haven't been able to figure out how this got written.

    […]

    I want to see it with a simple `ls' or `ls -l' command. A few of
    what I've tried:

    are:
    ls

    '--head--'

    \-\-head\-\-

    [\-][\-]head[\-][\-]

    […]

    As Janis already pointed out, "ls" and most of the standard
    utilities parse their argument list in the following manner:  They
    look at each of its arguments, starting with the left most and
    proceeding to the right:  If the argument starts with (at least) one
    "-" then they consider it to be an option except when they are told
    (see below) to not consider the remaining arguments as options.

    In your use case "ls" would consider "--head--" as a (GNU long)
    option.  In the case of a filename starting with a "-" that's a
    problem (as you encountered).

    But there is a remedy: the special option "--".  It tells the
    utility, that all following arguments are not to be interpreted as
    options, even if they look like an option, i. e. if they start with
    a "-".

    So the solution would be:  Before any non‐option arguments that you
    supply to "ls" always put that special end‐of‐options‐option "--" into the argument list:

    ls -- the filenames you want to specify …

    or

    ls -l -- the filenames you want to specify …

    This end‐of‐options‐option doesn't do any harm should it be not necessary, but it helps avoiding such surprises.

    It's become a habit of mine to always supply an
    end‐of‐options‐option no matter whether I think it's necessary or
    not.

    For example, the command


    ls -d [![:letter:]]*

    will show all filenames in the current directory that don't start
    with a letter or a ".".  If there happens to be a filename like
    "--head--" it will be put into the argument list and interpreted as
    an option.  Note:  If one looks at that command one might not know
    whether in the current directory there happens to be a filename
    "--head--".  That's why I wrote "no matter whether I /think/ it's
    necessary or not".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)