I think it will keep the spaces (not on a *nix box, but I think I may have already done similar in dev)

EDIT ... needed to cd to $DIR for this way to work

I also have an efficient recursive space replace script in the dev version if you are interested, but I don't keep files with spaces around, so not well tested - just 1-2 sub-directories or so. It only requires mv (not sed awk or grep as others do - it uses only the shell's internal substring manipulation - resulting in ~1000% speed improvement)

... right now I don't have a net connection at home so I'm trying to work on a dialog/Xdialog wrapper, so that scripts work independent of X/console (I think goingnuts may have done some work on this already?)_________________Web Programming - Pet Packaging 100 & 101

I think it will keep the spaces (not on a *nix box, but I think I may have already done similar in dev)

EDIT ... needed to cd to $DIR for this way to work

I gave this a try. Unfortunately there is still a problem. When the file or directory is evaluated by [ -d $DIR/$x ] if there is a space the test will throw an error. Quoting $DIR/$x causes the test to always fail. I think cd $DIR needs double quotes as well.

I will give the dev version a shot and see how it works.

EDIT: Which version is the dev version?

technosaurus wrote:

It only requires mv (not sed awk or grep as others do - it uses only the shell's internal substring manipulation - resulting in ~1000% speed improvement)

Thats pretty awesome. I never put much thought into the performance aspect of shell scripting.

I'll have to upload a new DEV version, but I need to transfer it to my droid or go find a hotspot somewhere (it may be a day or 2). My wife has our Altel internet stuff with her in Illinois._________________Web Programming - Pet Packaging 100 & 101

In puppy4 (maybe later versions) there was a 'pup4funcs' script or something ... it was sourced by many other scripts but never of much use to me in my scripts...

.. what would be *awesome* would be a directory of useful/repeatedly used scripts & funcs in /etc/* or /usr/lib/puppy/, that could be included in other stuff by puppy devs (and puppy itself, in its system scripts etc) .. this would reduce coding time, reduce redundant code in puppy userspace, reduce duplicate code, ease maintaining important system functions and features, and make it easier for newbies to start coding useful, safe, reliable apps of their own...

.. example funcs would include a lot of the funcs you wrote in bashbox

.. One reason to do this would be that Barry wrote pupdialog - then goingnuts, and myself, and others, also coded X/no-X UIs ... So a little library we could *all* use for this would be great..

For another (weak) example, we could have a file, /usr/lib/puppy/gtkdialog/pfselect

So, in any other script or app, we could call up a file selecter thingy, with only:

I was thinking about doing a rewrite so that more functions are split out into useful, generic functions. Zigbert did this to some extent, but I want to extend the traditional dialogs to actual "dialogs" (text2speech and voice recognition via espeak and pocket_sphinx_continuous) which is easier to do in a more structured approach. For example when a gtkdialog item list is generated, a corresponding voice menu is generated (if enabled) I'm considering extending the html generation with a httpd cgi backend as an alternative to gtkdialog (we could then use any browser for dialogs including netsurf-framebuffer/dillo or operate it headless/remotely)._________________Web Programming - Pet Packaging 100 & 101

Thanks for the 'lsof'. Too bad about the calls to readlink and sort. Of course the sort is probably not needed anyway. Can you think of how to implement readlink with only shell builtins?
As for the sort, I have a shell-only sort routine, or even better a uniq_no_sort routine. bash-only though as it uses arrays.

sc0ttman: Fully support your thoughts. Might be difficult though - as we tend to focus on/understand best/use... our own X/no-X UIs. The X part explodes in favorite flavors - Xdialog, GTKdialog(1/2/3), yafsplash, xmessage etc. Need a very easy to use abstraction layer and/or a narrow selection of toolkits in use...

@techno HeHe, I saw this: 'If you think this is appalling, check out BashTrix' in the sort thread. Hopefully the sort offered there is better than my proof-of-concept... It might compare favorably to the slim 'sort' in the thread if cut down to a similar size. All those things in BashTrix are necessarily long beacuse of handling some of the normal command-line options. And they are still longer because I coded them so they *might* be easier to read.

As for the thread about readlink, the suggested script is using readlink. I was asking about implementing readlink itself in shell.

The dialog/Xdialog/whiptail/kdialog interface is pretty well standardized (though, could use a few patches to make them more compatible). I could write a matching espeak/sphinx voice-dialog wrapper that can be used as a fairly straightforward template for other backends like yad or gtkdialog.

And this:
"'for' splits the input by line"
is not correct. 'for' splits according to the IFS, which by default is 'space tab end-of-line'. I know the comments are old, but felt it would be good to correct it -for posterity...

resets $@ to "" on the first iteration (note that this is after the original $@ has been passed to the for loop), on subsequent runs $@ is modified by inserting the current iteration's value into $@ at the sorted location._________________Web Programming - Pet Packaging 100 & 101