Comments (16)
Personally, I don’t mind. Do you?
I've opened this issue because automatic alias expansion looks like an important enough effect to warrant a mention in the docs. It's an odd thing to bundle with formatting.
Note that alias expansion can change the effect of typed commands. For example:
% alias echo='echo foo'
% echo bar
Normally this will print "foo bar" but with automatic formatting it'll print "foo foo bar".
There are also more obscure cases where automatic formatting introduces side effects. For example, try executing the following command:
: }; touch foo; () { :
Without automatic formatting this command fails to parse and does nothing. With automatic formatting it touches file foo
.
I don't mind any of it. Feel free to close this issue if or when you find it appropriate. Whatever you decide to do (including nothing at all) is fine with me.
from zsh-hist.
Yeah, I know. It’s a side effect of using $functions
to format the code. Personally, I don’t mind. Do you?
As a workaround, you can disable automatic code formatting with
add-zle-hook-widget -d line-finish .hist.format.hook
from zsh-hist.
Actually, I just realized it’s a side effect of using eval
. I’ll see if I can work around it/not use eval
for this.
from zsh-hist.
setopt localoptions NO_aliases
should probably do the trick. I’ll have to test it.
from zsh-hist.
Thanks for the detailed motivation. After reading this, I definitely want to fix it. It threw me off guard, too, the first time the alias expansion happened to me.
There are also more obscure cases where automatic formatting introduces side effects. For example, try executing the following command:
: }; touch foo; () { :
Without automatic formatting this command fails to parse and does nothing. With automatic formatting it touches file
foo
.
Ah, that’s nasty. I’ll definitely have to see if I can fix that. It probably won’t come up often, but it looks like it can have seriously bad side effects.
from zsh-hist.
Problem solved.
from zsh-hist.
I took a look at the fix. There are still corner cases where enabling auto-formatting will change the effect of commands. Example:
% alias -g ';'=
% echo foo; echo bar
Without automatic formatting this prints "foo echo bar". With automatic formatting it prints "foo" and "bar".
from zsh-hist.
Is there a real use case for a global alias like that?
from zsh-hist.
Is there a real use case for a global alias like that?
I don't know. Does it matter?
It would be useful to provide the following guarantee:
- Automatic formatting never changes the meaning of commands.
When you put it this way, it would appear very surprising if this guarantee weren't provided. Yet there are many violations of this guarantee right now. I've posted one example above. Here's another:
% emulate zsh -o extended_glob
% echo '
do
'
With automatic formatting the last command is rewritten to this:
echo '; do
'
The usual disclaimer applies: I don't have a personal preference one way or another. It's fine with me if you do nothing or change the code in any way you like.
from zsh-hist.
Hm, that last example is definitely a bug. I think I'll have to change my approach on how to implement this.
from zsh-hist.
Is there a real use case for a global alias like that?
I don't know. Does it matter?
Yes, that matters. It's a cost-benefit analysis: If there's no way this is going to bother anyone, then there's no value in fixing it. It's not worth it to spend time on things that don't benefit anyone.
from zsh-hist.
It’s not something I want to argue about.
from zsh-hist.
OK, I pushed in another fix. This should take care of everything except the global ;
alias thing.
from zsh-hist.
The guarantee I’ve mentioned above is still not provided even in the environment without aliases. Unfortunately, I’ve run out of goodwill to post more test cases. You’ll probably find them easily if you look at the code with the intent of seeing the bugs in it.
from zsh-hist.
@romkatv Patches welcome.
from zsh-hist.
I don’t know how to implement automatic parsing without changing the effect of entered commands. At the same time I think it crazy to use a plugin that can change the effect of typed commands in unspecified circumstances. I’ve opened this issue in case you find the information useful.
from zsh-hist.
Related Issues (18)
- Commands drawn from history cannot be executed. HOT 3
- Problems with unicode characters HOT 3
- Select multiple history entries HOT 3
- How to do a big-time auto format in place?
- TODO: Add installation instructions
- Regex `\b` replaced with `^H` in multi-line command HOT 2
- Don't add current command to history (`ignore` flag) HOT 2
- Plugin no longer working as expected after recent changes HOT 5
- Make plugin work with per-directory-history too, not just global history HOT 2
- ^Q unavailable in vi command mode
- hist: warning: $HISTSIZE should be at least 20% larger than $SAVEHIST HOT 1
- The term "undo" is used twice HOT 4
- Widgets are not found anymore HOT 4
- Code formatting ignores HIST_IGNORE_SPACE HOT 3
- Command line prepended with tab character. HOT 13
- History line autocompletion not working. HOT 1
- History line tab-completion not working. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsh-hist.