Tag Info

Hot answers tagged

23

Your confusion stems from the fact that many popular languages (especially C-based ones) stop evaluating && sequences when 0 is encountered, because 0 is considered false and everything else is true. In Bash, however, that's not the case. By convention, in POSIX systems (and all other Unix-like systems), return code 0 is considered SUCCESS (there was ...


8

The return value from commands are different from typical boolan values. 0 is success when executing a command, anything else is failure. && expects 0 to me success here for that reason.


4

Here, also using zsh, I have echo hai && echo bye hai bye And similarly echo hai && echo %? hai 0 Are you sure that you are seeing hai and bye on the same line with exactly the commands you have provided here? In direct answer to your question, an exit status of zero is success, so the second statement is executed. (This allows ...


3

In most cases, that would be the redirection operator (<): $ tr 'a' 'b' /path/to/file ## fails because `tr` works on streams tr: extra operand ‘file’ Try 'tr --help' for more information. $ tr 'a' 'b' < /path/to/file ## works because the file's contents are passed to tr Both command substitution and the redirection operator are defined by POSIX ...


3

According to the zsh user guide, aliases should be defined in ~/.zshrc: You may be able to think of some aliases you want to define in your startup files; .zshrc is probably the right place. It also has a tip for keeping your ~/.zshrc clean: I only tend to use aliases in interactive shells, so I define them from .zshrc, but you may want to use ...


1

You've completely banjanxed zsh's idea of what's been printed and what it has to erase/rewrite as it displays menu completion and lets you edit the command line. This is because you've overcomplexified that prompt. Don't use printf to just put a string literal inside a word. Don't use hardwired CSI control sequences to change colour. As I said at ...


1

Place your environment variables in your ~/.zshrc file, they will get sourced automatically on each zsh session.


1

Yuch, too much maintenance and too much individual stuff. I'd recommend putting most of the effort into having appropriately scoped names that are appropriate for the platform so you can just have all of them all of the time. PYTHONPATH is a good example... you're unlikely to want to repurpose it for a Ruby project... You can group and mark the group with ...



Only top voted, non community-wiki answers of a minimum length are eligible