简体   繁体   中英

How do I convert csh aliases into MODULEFILE compatible set-alias commands?

I have a bunch of aliases that I would like to share with co-workers and I would like to put it in our project modulefile . Is there a script that would do the conversion for me? Or at least give me a good start and then I could fix the ones that didn't translate well?

PS Could someone with more rep create a modulefile tag?

I don't know of any tool that does the translation, but you can use something like this if the aliases are all one-liners :

Firstly, make a Tcl script like this, eg, called convertalias.tcl :

while {[gets stdin line] >= 0} {
    if {[regexp {^alias (\w+)='(.*)'$} -> name def]} {
        puts [list set-alias $name $def]
    } else {
        puts stderr "Rejected line: $line"
    }
}

Then use it in a bash command line like this (where bash$ is the prompt):

bash$ alias | tclsh convertalias.tcl >aliases.def

You'll then have to hack the aliases.def file, but it should give you a start. It will also print out any lines it couldn't grok (after all, it's just a stupid script...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM