GiselleSerate / myaliases

Useful shell aliases and functions.
6 stars 1 forks source link

$ edge case #54

Closed GiselleSerate closed 6 years ago

GiselleSerate commented 6 years ago

What if you want to use a variable in your nickname but you want it evaluated on src instead of on calling altalias? Use single quotes: '$var1'="commands"

Use cases: Uh . . . call with username?

Consider whether you even want this behavior or if someone would find this useful. It's undefined by alias.

aryarm commented 6 years ago

Hey, also I think I'm still misunderstanding something. What was the filter originally for? Because alias $var1='cds' and alias $(echo 'cd')='cds' should work without filtering, right? I didn't have to put double quotes around those for them to work. As long as there are double quotes around $1 it should be fine, right? Doesn't bash evaluate and resolve lines with a $ sign before they're executed? image

GiselleSerate commented 6 years ago

Yeah, I guess you're right . . . the filter currently only removes the = because I left it in my regex. So I guess as long as the alias name expression doesn't involve assignment, the filter should work fine.

aryarm commented 6 years ago

Yeah, and = is not a valid character in alias names anyway. Ultimately, I don't think you should have to use regex at all, right?

GiselleSerate commented 6 years ago

Well, I used regex to isolate the alias nickname bit so I could call alias again to figure out the expression it stored. But I didn't do regex to change what the person used as their nickname.

aryarm commented 6 years ago

ah ok makes sense and once you have that alias nickname, you use it to delete a line in .usr_aliases that already declares that alias, right? ah ok everything is making sense now

GiselleSerate commented 6 years ago

I think we're going to say if it's undefined by alias, we will also leave it undefined.