0

I'd like to create alias to run a program. My alias is as follows: alias cc=g++ -Wall -Wextra $1 -o $1. This way I could write cc app.cpp and the command would be g++ -Wall -Wextra app.cpp -o app.exe

However, there is a problem.

$1 give filename with extension but I need only filename. Is there a workaround? doskey and ConEmu don't have a variable for a filename without extension. Such a variable has for example for in cmd.exe. It is %A.

2

1 Answer 1

0

This turned out to be easy as @Ƭᴇcʜιᴇ007 has provided useful link. Just create a bat file and paste this:

@echo off
SETLOCAL
for %%i in (%1) do (set filename=%%~ni)
g++ -Wall -Wextra %1 -o %filename%.exe

Tested and it works fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .