Re: Avoid asterisk expansion when it selects "everything"

2016-04-14 Thread Andreas Schwab
Mike Frysinger  writes:

> alternative idea: alias your rm/mv/etc... commands if you're worried
> about them.  it's not uncommon to do in ~/.bashrc or wherever:
>   alias rm='rm -i'

That's the worst advice you can give.  If you lose the alias for
whatever reason you get silent failure.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Re: Avoid asterisk expansion when it selects "everything"

2016-04-14 Thread Mike Frysinger
On 14 Apr 2016 09:23, Andreas Schwab wrote:
> Mike Frysinger  writes:
> > alternative idea: alias your rm/mv/etc... commands if you're worried
> > about them.  it's not uncommon to do in ~/.bashrc or wherever:
> > alias rm='rm -i'
> 
> That's the worst advice you can give.

hyperbole much ?

> If you lose the alias for whatever reason you get silent failure.

you mean you get the status quo.  oh no!
-mike


signature.asc
Description: Digital signature


Re: Avoid asterisk expansion when it selects "everything"

2016-04-14 Thread Andreas Schwab
Mike Frysinger  writes:

> On 14 Apr 2016 09:23, Andreas Schwab wrote:
>> Mike Frysinger  writes:
>> > alternative idea: alias your rm/mv/etc... commands if you're worried
>> > about them.  it's not uncommon to do in ~/.bashrc or wherever:
>> >alias rm='rm -i'
>> 
>> That's the worst advice you can give.
>
> hyperbole much ?

No, I mean it.

>> If you lose the alias for whatever reason you get silent failure.
>
> you mean you get the status quo.  oh no!

If you depend on the safety net you lose.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Re: Avoid asterisk expansion when it selects "everything"

2016-04-14 Thread Stephane Chazelas
2016-04-13 11:23:01 +, Anis ELLEUCH:
> Hello everybody,
> 
> I would like to ask if it is possible to disable expanding asterisk when it
> selects all entries ?
> 
> `$ rm * .jpg` with a mistaken space between asterisk and .jpg will delete
> everything in your home directory or in the entire disk.
> 
> In my opinion, when the user asks to select "everything" which could be `*`
> or `path/*`, bash has to show a confirmation prompt to check if the user
> was not mistaken, this option should be obviously disabled by default
> 
> Another idea: `*` and `/*` should not be interpreted and the user has to
> enter another sequence "more powerful" to emphasize selecting all entries (
> `^*` would it work just fine ?)
[...]

zsh does that by default:

$ rm * .jpg
zsh: sure you want to delete all the files in /tmp [yn]?

(disabled with "setopt RM_STAR_SILENT")

Also in tcsh, though not enabled by default there:

> set rmstar
> rm *
Do you really want to delete all files? [n/y]

(they match on "rm *" or "rm dir/*")

For bash, you can try this approach:
https://unix.stackexchange.com/questions/108803/preventing-deletion-of-system-shell-aliased-folders/108854#108854

-- 
Stephane



Re: Coprocess terminated, pipe closed before I read the data out

2016-04-14 Thread Chet Ramey
On 4/13/16 1:13 AM, George wrote:

> Users can work around this by duplicating the file descriptor:
> $ exec {fd_that_wont_vanish_on_me}<&${coproc[0]}-
> But it kind of negates the benefit of having coproc accept a name for
> the fd array if you just wind up having to re-bind it anyway. And the
> command could still fail if it's not run immediately after launching
> the coproc.
> 
> Thus, I think coproc shouldn't close its file descriptors or erase its
> environment variables.

This an interesting suggestion.  I will look at it for a future version.
You have to be careful with writing to a pipe where the reader has gone
away, though, since that will generate SIGPIPE.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/