Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PATHEXT for Bash?

Name: Anonymous 2006-05-25 7:16

Is there any kind of PATHEXT for Bash?

PATHEXT, a feature of CMD.EXE and the Windows shell API, is like PATH for file extensions. If, for example, you set it to ".EXE;.PL", and launch "lol", for each directory in PATH, it will try to find "lol" as is, then "lol.EXE", then "lol.PL". Windows will start the first file found.

Start means it'll look for the default shell action and do it. If it's a Perl file, it'll run it through Perl. If it's an executable, it'll directly execute it. This avoids having to do the #!/lol_my_folder_is_different/perl shit in scripts) and allows you to launch anything associated with any command. I don't expect this to be possible under Lunix because you have no global file associations, but would at least there be a PATHEXT equivalent?

Name: Anonymous 2006-05-25 7:45

cd /; chmod -R +x *.yourextension;

Name: Anonymous 2006-05-25 8:09

There is no file association because there is no file extension for programs. With "Lunix" (haha your teh funny) you can execute a text file as a program, you can't do this on non *nix systems (not that I use this crappy method but you started the flamewar anyway...)

Name: Anonymous 2006-05-25 9:13

>>2
That doesn't do what I want; I want to launch my Perl, Python, PHP, etc. scripts without having to type the extension (.pl, .py, .php, etc.) all the time, and while being able to tell which language is what (hence the extension) for a number of reasons.

>>3
Told ya I was funny ^_^. I already know that, but I find no extensions means you're not able to tell what an executable is beforehand - whether it's executable code, a shell script for some shell, or an interpreted script in some language, etc.

And oh, no associations is a feature? Ok, please make it so that whenever I execute an image I can view it in xzgv, and add a generic print method for printing anything, for example.

Name: Anonymous 2006-05-25 9:25

>>1

zsh can do it, fuck knows about bash.

Name: Anonymous 2006-05-25 9:53

best thing to do is create a small shell script entitled "start" or whatever that does what you say.  you can do the same for printing.

Name: Anonymous 2006-05-25 10:02

>>4 have you herd of a command named "file"?  tells you the filetype.

continuing from >>6, really, if you like this capability, you can build a lot of effective features in that script.  furthermore, you probably want to use the file command rather than checking "extensions", even though that will require some string manipulation ... and you can define/use whatever environment variables you want.

Name: Anonymous 2006-05-25 10:38

>>6
>>7

Guys, telling him to go away and write scripts is obviously not something he's into. Otherwise he'd have done it already.

Really, just get zsh and a decent .zshrc

Name: Anonymous 2006-05-25 14:34 (sage)

just get zsh and a decent .zshrc
the only way to get a decent .zshrc is to write it yourself.
telling him to go away and write scripts is obviously not something he's into.

Name: Anonymous 2006-05-25 17:40

>>8
I can script in 4-5 different languages including Perl. In fact I have a quite decent collection of personal scripts to deal with a number of things. The reason why I asked is that I don't like to duplicate efforts and I don't like to write what somebody else already did, or what's theres some kind of short hack for. I just wanted to see if there's something like this before I do it myself, thank you.

>>9
the only way to get a decent .zshrc is to write it yourself.
Thought so, it's the same with other shells and software I've tried. I wonder why don't we publish the good shit once we come up with it.

Name: Anonymous 2006-05-25 21:13

it's NOT THAT HARD to take apart the filename (first command line parameter) and invoke a program based on what it is.  A good learning project.

Name: Anonymous 2006-05-26 2:08

>>11 you can't count on the filename being the first parameter, with something such as what >>1 is looking for, it doesn't matter wether the file name was invoked first or last.

Name: Anonymous 2006-05-26 2:36

>>12
if you make a script called "start", which takes the filename as first command line parameter, yes you do.  it's always the first parameter.

Name: Anonymous 2006-05-26 3:17

>>11
It's not hard, but like I said, I wanted to know if there was something to do this already, and if I could spare me of the extra script. (Admittedly, there's not much of a difference between typing "s lol" vs. "lol.pl". Even so, it'd be worth if I implement file methods like Windows, i.e. besides running, you can "view", "edit", "print", etc. files which calls different commands based on the file type.)

Name: Anonymous 2006-05-27 15:41

>>4
are you looking for hashbang or something? start your file w/ '#!/usr/bin/whatever', where 'whatever' is perl or python or bash or whatever (dunno if you can hashbang PHP)

but what's it matter what the extension is anyway? most *nix programs don't even have an extension. you could rename a perl script pr0n.jpg or MuZaK.mp3 and it'll still run fine.

Name: Anonymous 2006-05-27 15:58

>>15
He WANTS extension to know what sort of program he has without having to open the script. When it comes to the execution he is too lazy to type the extension.

Is that so hard to understand?

Name: Anonymous 2006-05-27 18:53 (sage)

Is that so hard to understand?
no, what's hard to understand is how it took you so long to figure that out.

Name: Anonymous 2006-05-28 5:37

Basically the author wants to be able to store metadata in the filename. That's not the Right Thing. gb2/DOS/.

Name: Anonymous 2006-05-28 12:19

>>18
It's better than storing metadata within the file, isn't it?

Name: Anonymous 2006-05-28 12:55

>>19
That's like asking what's better, a nigger or a jew.

Name: Anonymous 2006-05-28 12:56

>>19
no, it's not, because then you have problems like he's having right now. if the metadata was stored in the file, he wouldn't have this problem.

>>16
it's not hard to understand WHAT he wants, it's hard to understand WHY he wants it. instead of doing, say, >>15

Name: Anonymous 2006-05-28 13:36 (sage)

>>21
He wants to know what sort of program he has without having to open the script.

Is that so hard to understand?

Name: Anonymous 2006-05-28 13:56

>>22
USE THE UNIX 'file' COMMAND THEN.

$ file nickelsAD.jpg
nickelsAD.jpg: JPEG image data, JFIF standard 1.02

$ file ch01s06.html
ch01s06.html: HTML document text

$ file ch01s06_files
ch01s06_files: directory

IT'S NOT HARD

Name: Anonymous 2006-05-28 14:26

Okay, you win, I fail.

Name: Anonymous 2006-05-28 15:28

>>21
If the metadata is stored in the data (which, by the way, sounds like an ugly idea as you can see), you have to open every file to tell what it is.

>>22
Nooooooooooooooooooo read the goddamn thread.

Name: Anonymous 2006-05-28 16:21

yes pathext... and and the next minute you executing virii jpgs
http://www.milw0rm.com/exploits/1821

Name: Anonymous 2006-05-29 15:40

>>26
Only if you're as stupid as to include .JPG in PATHEXT AND as stupid as to define JPG as an executable. That's too much stupidity even for end lusers, who don't know what's PATHEXT or how to edit your HKCR.

Name: Anonymous 2010-06-07 6:42

Hi, I can spam /prog/ too, you faggot.

Also, smoke weed everyday.

Name: Anonymous 2011-02-03 4:36

Name: Anonymous 2011-12-01 18:34

Name: Sgt.Kabu쏢㏉kiman涭碥 2012-05-28 18:58

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List