You are not logged in.

#1 2009-06-10 22:03:44

dezza
Member
From: Denmark
Registered: 2007-04-05
Posts: 126

Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

[dezza@dezza Zen Mechanics - Holy Cities (FLAC) (2008)]$
alias flac2mp3="flac -sdc $1 | lame -V2 --vbr-new - $2"

[dezza@dezza Zen Mechanics - Holy Cities (FLAC) (2008)]$
flac2mp3 "01. Zen Mechanics - Modified.flac" Modified.mp3

lame: excess arg Modified.mp3

How can it be that it works like "flac -sdc $1 | lame -V2 --vbr-new - $2" but not when wrapped into an alias?

Thanks in advance!

Last edited by dezza (2009-06-10 22:13:21)

Offline

#2 2009-06-11 12:38:08

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

An alias doesn't know anything about $1 or $2.
However - you _could_ make it into a function - thus:
flac2mp3() { flac -sdc $1 | lame -V2 --vbr-new - $2; }

Last edited by perbh (2009-06-11 12:38:30)

Offline

#3 2009-06-11 14:58:40

dezza
Member
From: Denmark
Registered: 2007-04-05
Posts: 126

Re: Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

But I have another alias where I use $1 in it and it works fine?

Offline

#4 2009-06-11 15:01:51

Wra!th
Member
Registered: 2009-03-31
Posts: 342

Re: Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

dezza wrote:

But I have another alias where I use $1 in it and it works fine?

It may be an illusion. like alias play=mplayer $1
When you run `play hahaha.mp3` it will actually try `mplayer $1 hahaha.mp3`, will fail to find `$1` as a file, and start `hahaha.mp3`.
I have a hunch this is the case. Alias has no parameter parsing afaik (make a script for that instead)


MacGregor DESPITE THEM!
7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Offline

#5 2009-06-11 17:22:13

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

Considering what you're trying to do, i thoroughly recommend you quote those parameters

flac2mp3() { flac -sdc "$1" | lame -V2 --vbr-new - "$2"; }
                       ^  ^                        ^  ^

It will probably save you some headaches from filenames with spaces in them...


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#6 2009-06-11 18:02:23

dezza
Member
From: Denmark
Registered: 2007-04-05
Posts: 126

Re: Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

Interesting .. You might be right ..

But if I assign the function first:
flac2mp3() { flac -sdc $1 | lame -V2 --vbr-new - $2; }

What should the alias line look like? And will the function be there for the next time I open up a terminal?

Offline

#7 2009-06-11 18:48:26

SamC
Member
From: Calgary
Registered: 2008-05-13
Posts: 611
Website

Re: Creating simple alias (flac2mp3) with 2 variables(ERR:lame excess arg)

Put the function in your ~/.bashrc, and run it with "flac2mp3". You don't need an alias.

Offline

Board footer

Powered by FluxBB