Bug - Not A Bug alias and inv conflict in the cli

nworbetan

Member
I just added this recently:
Code:
[COLOR=olive]> alias coffee[/COLOR]

[B]coffee [/B]=> ash item icps = $item[coffee pixie stick]; if (available_amount(icps) * 10 + available_amount($item[game grid ticket]) < 40) cli_execute("skeeball " + (4 - available_amount(icps))); if (available_amount(icps) < 4) retrieve_item(4, icps); retrieve_item(1, $item[mojo filter]); use(3, icps); use(1, $item[mojo filter]); use(1, icps);

It works, and I'm happy with it, but now this happens:
Code:
[COLOR=olive]> inv coffee pixie stick[/COLOR]

[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator[/COLOR]
[COLOR=red]KoLmafia declares world peace.[/COLOR]

The world peace declaration was actually me hitting the escape key.

If the solution to this ends up being moving that alias into a script, that'll be fine by me, but the infinite error messages looked like something someone might want to know about.
 

Winterbay

Active member
I think the problem is that you have the word coffee as your alias and within the alias but I may be wrong.
 

Veracity

Developer
Staff member
aliases work any where in the command line.
You have an alias named coffee.
You used the token "coffee" in a different command.

This is working as expected.

I notice that your alias named "coffee" has the token "coffee" in it. Obviously, that's not hurting you when you use "coffee" as your command and it turns into an ashq command, which will do no further alias expansion, but when your alias is expanding in the context of command arguments for the "inv" command, it does not surprise me that it recurses.

Bottom line:either make a script named "coffee" or choose a different name for your alias.
 

nworbetan

Member
aliases work any where in the command line.
You have an alias named coffee.
You used the token "coffee" in a different command.

This is working as expected.

Okay, I'm with you 100% so far.

I notice that your alias named "coffee" has the token "coffee" in it. Obviously, that's not hurting you when you use "coffee" as your command and it turns into an ashq command, which will do no further alias expansion, but when your alias is expanding in the context of command arguments for the "inv" command, it does not surprise me that it recurses.

My alias has the token "coffee" in it in the exact same way that this command uses the "coffee" token:
Code:
[COLOR=olive]> ash $item[coffee pixie stick][/COLOR]

Returned:     coffee pixie stick
plural => coffee pixie sticks
descid =>     936288573
image => cpstick.gif
levelreq => 4
quality =>
adventures     => 5-10
muscle => 0
mysticality => 0
moxie => 0
fullness     => 0
inebriety => 0
spleen => 4
notes =>
combat =>     false
reusable => false
usable => false
multi => true
fancy     => false
candy => false
bounty => none
bounty_count => 0
seller     => Arcade Ticket Counter
buyer => none
name_length => 18

And no substitutions happened there. The bolded "coffee =>" in that first code block is part of the output of the alias cli command, is that what you're seeing as the problem, or am I misunderstanding?

Bottom line:either make a script named "coffee" or choose a different name for your alias.

Will do. ;)
 

Catch-22

Active member
I don't really make extensive use of aliases. Is there a reason why an alias should be expanded when it's not the first word of a command string?

Edit: or after a ";".
 
Last edited:

Catch-22

Active member
Ah so an alias can really just be any string... Interesting :) *To the lab!*

Edit:

> alias alias => print you broke it!

String successfully aliased.
alias => print you broke it!

> help alias

No matching commands found!


MUHahahhaha
 
Last edited:

Veracity

Developer
Staff member
Obviously, that's not hurting you when you use "coffee" as your command and it turns into an ashq command, which will do no further alias expansion, but when your alias is expanding in the context of command arguments for the "inv" command, it does not surprise me that it recurses.
Notice the distinction between interpreting text as ASH code vs. interpreting text as CLI commands.

My alias has the token "coffee" in it in the exact same way that this command uses the "coffee" token:
Code:
[COLOR=olive]> ash $item[coffee pixie stick][/COLOR][/quote]
Correct. Your alias makes an "ashq" command, your example is an "ash" command.

Alias expansion does not happen when the CLI is interpreting text as ASH commands - in an "ash" or an "ashq" command.
 

nworbetan

Member
Okay then, now that I think I get it, can I turn this into a feature request that during alias expansion, treat all tokens following "ash" or "ashq" as if it were ash code instead of gcli input? Maybe make exceptions for strings used by cli_execute(string)?

Not saying that either of these things would be easier than just moving my two lines of alias into a script, just throwing ideas around and seeing if anything sticks.
 

Catch-22

Active member
+1 that feature request.

> alias aliastest => print("test");

String successfully aliased.
aliastest => print("test")

> ash aliastest

test
Returned: void
 

Bale

Minion
Catch-22, that is not what nworbetan suggested. His suggestion still requires an ash or an ashq in the alias. Your interpretation would break a lot of aliases. His idea is to keep alias expansion from happening after one of those two tokens.
 

Veracity

Developer
Staff member
Obviously I was incorrect: we do expand aliases, even when the command is an AshSingleLineCommand. And looking at Aliases.apply, it should not recurse. So, I have no explanation for the looping error you were getting.

I still advise you to make a script or use an alias name that you will not want to use as a token in another command; do you REALLY want "inv coffee pixie stick" to expand into "inv ash ...a bunch of ash code... pixie stick"?

I didn't think so.
 

Catch-22

Active member
His idea is to keep alias expansion from happening after one of those two tokens.

Hmm so an alias should only continue expanding if it hasn't expanded an ASH statement? I guess so, but don't you find this behaviour odd?

> alias aliastest => This isn't my string.

String successfully aliased.
aliastest => This isn't my string.

> ash $string[" aliastest "].print()

" This isn't my string. "
Returned: void
 

nworbetan

Member
do you REALLY want "inv coffee pixie stick" to expand into "inv ash ...a bunch of ash code... pixie stick"?

I didn't think so.

I've been misusing aliases as a kind of "build your own cli command" kind of thing, and completely forgetting, you know, what they really are. The fact that it's taken me this long to accidentally name one them so badly is kind of surprising.
 

xKiv

Active member
In the meantime, you should be able to
Code:
alias anything => whatever %%
to only expand "anything" if it's the first word (any alias containing %% was doing that last time I checked).
As an added "bonus", it will not work if you "call" it with "wrong parameters".
Maybe you can "# %%"? (comment it out?)
 

nworbetan

Member
the looping error

I'm still 100% okay with the solution, and fully realize that "inv <this specific ash code>" is so malformed that it's practically gibberish.

But as it turns out it's not actually infinite either.

Code:
> alias somethingelse

somethingelse => ash item icps = $item[coffee pixie stick]; if (available_amount(icps) * 10 + available_amount($item[game grid ticket]) < 40) cli_execute("skeeball " + (4 - available_amount(icps))); if (available_amount(icps) < 4) retrieve_item(4, icps); retrieve_item(1, $item[mojo filter]); use(3, icps); use(1, $item[mojo filter]); use(1, icps);

> inv somethingelse

Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
Invalid operand [40) cli_execute("skeeball " + (4 - available_amount(icps)))] on right side of operator
(available_amount(icps) * 10 + available_amount($item[game grid ticket]) 40) cli_execute("skeeball " + (4 - available_amount(icps))) is not a valid construct.
40)>

It's always 56 repetitions of that one line, and the four characters on that last line are in black instead of red.
 
Top