rakitzis / rc

rc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
Other
250 stars 23 forks source link

Can't overwrite commands #78

Closed nnzv closed 2 years ago

nnzv commented 2 years ago

Description

Set a command as function will break current session. No logs, it's just like calling exit.

Reproduce

  1. Declare fn ls { ls -FC $* }
  2. Execute ls

Expected behavior

Overwrite the command itself, but adding parameters.

Environment

OS: Gentoo Linux Version: rc-1.7.4-r2

entity0xfe commented 2 years ago

That's because you call your self declared function within it self, resulting in a loop. Declare the inner ls with full path or as

fn ls { `{which ls} -FC $* }
nnzv commented 2 years ago

Oh, true. But should we call it a loop? Just breaks. Thank you, though.

[Edit] Here's another way to do it:

fn ls { builtin ls -FC $* }