Alias with space in the name

Jun 8, 2013
98
0
Warsaw, Poland
I hope I'm using proper syntax this time :)

I'm trying to define command alias with space inside.

for example:
content of file the xyz
z1 x1=nothing1
"z2 x2"=nothing2
'z3 x3'=nothing3
`z4 x4`=nothing4​
alias /R xyz & alias
z1=x1=nothing1
"z2=x2"=nothing2
'z3=x3'=nothing3
`z4=x4`=nothing4
None of them is defined:
[Z:\P Apps\PortableApps]"z1 x1" & "z2 x2" & "z3 x3" & "z4 x4
TCC: Unknown command "z1 x1"
TCC: Unknown command "z2 x2"
TCC: Unknown command "z3 x3"
TCC: Unknown command "z4 x4"

Of course, if there would exist file "z1 x1.exe" it could be executed using "z1 x1" command.

Is it possible to create alias with space in name?

====
TCC/LE
 
Last edited:

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,463
88
Albuquerque, NM
prospero.unm.edu
An alias is a command.* An unquoted space ends a command; an unquoted space therefore ends an alias name. If you type
Code:
alias foo bar=baz
... you are creating an alias named FOO, with the value BAR=BAZ. That much makes sense to me. It's even sort of documented, in the BNF in the help page for the ALIAS command.

Why you can't use quotes to create an alias named "FOO BAR" I don't understand. Probably there has never been any demand for such a feature. After all, you'd have to type the quotes to use the alias, which kind of defeats the point of using an alias in the first place.

* Well, unless it's a keystroke alias. Or a directory alias. One of those other things you create with the ALIAS command.
 
Jun 8, 2013
98
0
Warsaw, Poland
You cannot create aliases with embedded whitespace. (And I don't understand why you would want to -- can you elaborate on that?)

If cannot create, another ways exist...

There are two reasons.
In general: I'm using some auto-configuration scripts. My idea is, that they had to be "space aware" as close as possible. As you can see, my latest issues are based on something like "P<space>Apps" directories. Personally I don't like spaces - spaces are difficult to be handled, filenames have to be quoted, filename autocompletion is ugly, *IX tools like MSYS are not space aware, and ... there are many more cons.

Anyway. My script examines specific directories for executables: %BASE_DIR\*\*.exe and assigns aliases to all of them.

1.
Code:
alias %@name[%file]=%@Quote[%TrueName[%file]]
In most cases there is exactly one executable per directory, in my opinion polluting %path in that case is a waste of resources (and it is not good practice).
If I can't embed space into alias - doesn't matter, I'll skip such executables, I'll show warning, or sth.

2.
I have the same executables in several dirs. In particular: I'm using one copy of eclipse per one project. All of them are very different, currently I'm using: 2x C++ CDT, 1* Perl Epic, 1x Java SE. IMO it is the easiest way to avoid influences between very different configurations. It is is easier than maintaining one eclipse and several workspaces. So all aliases from previous example are wrong. The first, the simplest approach was do define aliases like:
Code:
alias "eclipse <parentDir>"=%@Quote[%TrueName[%file]]
If I can't embed space into alias - doesn't matter, I'll create alias for "eclipse" (in that case). Something like (there are missed quotes and "If isFile eclipes.exe" checks, it is only the draft)
Code:
alias eclipse=%BASE_DIR\%1\eclipse.exe
There are some problem in the implementation stage, but it will provide more usable environment - eclipse perl (without quotes) is better then "eclipse perl" (with quotes) :)

-------------------

BTW: I'll share my work (800+ LOC 4Start.btm), but there are some legal issues (I'm working for large SW company, and (in theory) all my ideas belong to my employer; but my employer is not interested in that :)
 
Similar threads
Thread starter Title Forum Replies Date
D Can alias pass parameters to for command? Support 3
Jay Sage Issue with CD_ENTER Alias Support 37
Jay Sage Issue with CD_LEAVE Alias Support 3
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
R @select inside alias gives different (insanely small) window Support 7
kb6ojs ALIAS with multiple commands? Support 9
vefatica Can I alias @@Ctrl-Shift-Alt-u? Support 4
D Alias with setdos no longer works Support 21
vefatica TPIPE in an alias? Support 2
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
Peter Murschall CMDebug 26.01.37 has problems with Alias Support 21
samintz How to? Alias or prompt? Support 1
MickeyF expand alias in cmdline with Ctrl-F in TCC Support 21
Jay Sage Directory Alias Access to FTP Servers Support 2
rps How to? Shralias and producing history.sav, alias.sav .. Support 6
J Alias @@F5 hotkey Support 2
vefatica alias.sav not accurate Support 8
Joe Caverly Using a Directory Alias with @iniwrite fails Support 14
N multiple command alias and redirection Support 0
vefatica SETLOCAL ... ALIAS ... pipes Support 2
B TCC 21.01.50 Problem with ALIAS /r and SET /r Support 2
rps How to? Alias/Command line use of *log on/off Support 2
MickeyF alias terminating before it should Support 3
JohnQSmith ALIAS /R in TCSTART.BTM Support 9
D Alias in batch file Support 3
vefatica Can't execute @ALIAS[...] Support 5
E How to? Load Alias File on Startup Support 3
I Windows 10 console does not allow alt-F4 alias to complete Support 1
MickeyF create an alias with optional parameter Support 4
nickles Alias expansion Support 7
T scrput `` in alias or function Support 2
vefatica Alias works differenltly v16 vs. v17 Support 13
B Alias with multi line definitions not assigned Support 6
jbanaszczyk Alias for internal command Support 8
D Clear alias parameters Support 7
T Fixed multi-line alias issue Support 13
keithg1964 WAD 16.0027 Alias /rz bug Support 8
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
tmaynard How to? Control-U alias for Escape (command line editing) Support 5
C Alias ListEmptyFldrs=??? Support 4
M How to? Put logic into an alias... Support 6
G How to? v15: Can't alias Alt-Z Support 7
nikbackm v15: Problem with ALIAS in command group Support 10
vefatica WAD DO i=1 TO %# in an alias? Support 9
cgunhouse Directory Alias Issue Support 7
C CMD window size and post_exec alias ? Support 6
deleyd How to? Alias in TCMD.INI file? Support 2
M How to? Run a command (alias, actually) on a "timed" basis... Support 13
A strange error in alias Support 9
J Initialise; Alias; Extended directory search Support 2

Similar threads