Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle quoted paths #398

Merged
merged 2 commits into from
Oct 13, 2015
Merged

Handle quoted paths #398

merged 2 commits into from
Oct 13, 2015

Conversation

mikesigs
Copy link
Contributor

I was annoyed at having to use short paths all the time in my aliases. It wasn't until I found a command that actually refused to work with a shortpath (running iisexpress.exe) I was determined to find a solution.

Quoted paths weren't working whenever the script used "%*". You'd get an error like "File was unexpected at this time."

The additions on lines 6-7 wrap the input in quotes and then strip the inner quotes. This variable is used in the for loop (instead of %*) for validating the alias. It's also used in the first usage check.

I also renamed a variable and indented a couple things.

The command I used as my test was:
alias runapi=runas /netonly /user:domain\user "c:\Program Files (x86)\IIS Express\iisexpress.exe /site :WebAppName /trace:i"

I was annoyed at having to use short paths all the time in my aliases. It wasn't until I found a command that actually refused to work with a shortpath (running iisexpress.exe) I was determined to find a solution. 

It appears that the reason the quoted paths weren't working was due to the ::validate alias stuff. The for command would stumble on a quoted path, arguing that /foo was unexpected...

The additions on lines 7-8 wrap the input in quotes and then strip the inner quotes. This variable is used in the for loop (instead of %*) for validating the alias. So long as the alias is valid (contains no spaces) then the existing method of appending the new alias to the aliases file works just fine because it still uses %*.
@mikesigs
Copy link
Contributor Author

Accidentally sent a pull request yesterday to master. Sorry for the noob maneuver. Hopefully this PR is better.


set _temp=%_temp2: =%
:: validate alias
for /f "delims== tokens=1" %%G in ("%_x%") do set alias=%%G
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, since %_x% usage is not needed in arguments check (line 10) then it is better to move its definition to actual usage here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the %_x% is needed in the arguments check, the declaration must remain at the top of the file.

@vladimir-kotikov
Copy link
Contributor

👍

@Stanzilla
Copy link
Member

@mikesigs can you rebase, please?

@mikesigs
Copy link
Contributor Author

@Stanzilla Done and done.

Stanzilla added a commit that referenced this pull request Oct 13, 2015
@Stanzilla Stanzilla merged commit 052ab11 into cmderdev:development Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants