Sponsored Content
The Lounge What is on Your Mind? Speculative Shell Feature Brainstorming Post 302508984 by Corona688 on Tuesday 29th of March 2011 02:37:50 PM
Old 03-29-2011
Quote:
Originally Posted by tetsujin
One can take this argument to the extreme: say anything that's not part of one of the "standard" commonly-used shells is not a feature of a "shell language". If it wasn't invented at least 15 years ago and implemented as part of something with "sh" in the name, it's no good.

One could also take the broader view: if features are identified that could be of value, find a way to incorporate them while still keeping the shell as conceptually sound as possible.
I've already suggested several ways.

I think the argument comes down to this.
Quote:
Because if file descriptors are "just integers" then the shell can't manage their lifetime.
Yes you can. Yes, you, can.

The main thing you wanted, close-on-exec, is a kernel feature. One ioctl and it's done. The FD isn't just sufficient for it -- it's mandatory.

Any other kind of scoping you could possibly want is still doable too. The shell just has to keep track of it internally, like local variables, instead of crutching it with a "special" variable.

It might be easier for you as the programmer of the language -- on first glance, anyway -- to add all these new special kinds of variables, but I think you'll paint yourself into a corner really quickly. And paint other people into a corner besides.

---------- Post updated at 12:37 PM ---------- Previous update was at 12:05 PM ----------

Quote:
Originally Posted by tetsujin
The whole concept of storing "objects" in shell variables is a bit outside of the usual expectations for a Unix shell, so it's bound to be a contentious idea - I don't think the argument about it is getting us anywhere.
The point is, you don't need to. There's ways of doing what you want without breaking the very concept of a shell variable.

Anyway.
Quote:
Another feature I've been thinking about: parallelizable loops.
Of course, you could just add an & to the end of that to get what you want, but I think I know what you're getting at. I've thought about that a fair bit myself, and noticed the same problems.

One possible solution, I think, would be pipes. Instead of giving everything a raw stdin/stdout, give them pipes. The shell will read and print output from their stdout pipes in order to enforce proper order of their outputs that way. Completely silent commands will run completely parallel. Ones that aren't might still accomplish some work before the pipe blocks. (You could use temp files instead of pipes for stdout to make a larger 'buffer'.)

stdin would work similarly. As long as process #1 is alive, the shell feeds stdin input into its input, and only moves on to process #2 once process #1 dies. There might also be situations where you'd want it to work in a round-robin fashion, first line going into process 1, second line into process 2, third into 3, fourth into 1, etc, etc.

Interactive commands wouldn't work right, but that goes without saying. To make interactive commands work in parallel, each one would need their own independent virtual terminal -- which is possible but the CPU costs of that could start adding up.

You don't need screen to do that, by the way. Any C program can create a PTY.

I'm not exceptionally concerned about running mounds of interactive things in parallel, really. Usually that doesn't make sense. Things you might want to do that to, like ssh, have anticipated this and have noninteractive mechanisms to accomodate this. For really badly thought-out applications, or things which really, really demand a real human be there, we have the expect language -- a last resort, as it should be.

Synchronizing variables would be more of a problem. I'm not 100% sure how it'd work yet, but I can envision the shell processing a set of lines and compiling an order of operations that it shoves into a queue(okay, these four processes all set this variable once, and the thing below this loop reads it once, so let the loop finish before reading this variable...) ...then following it lock-step to give each operation. It helps that these aren't processes, but always shell syntax or program output fed into shell syntax. A program's never going to do an end-run around us and set a shell variable with a system call or anything. Maybe something like a semaphore, keeping a use-count that unlocks it once there's nothing behind you in line using it... Reading or setting a variable means waiting your turn, reading or writing to stdout means waiting your turn, anything else lets you scream on ahead.

Quote:
There are also various cases of commands that aren't full-on TTY apps, but which do use the TTY (progress bars in wget and so on)
wget can print progress to non-terminals, it just prints lines of dots.

ls is also one of these special commands. When it prints to a terminal, many implementations can print multiple columns, but they switch to single-column output when the output isn't a terminal.

In both cases the output is useful either way when the thing reading them is a script instead of a human, so I don't think it's too important.

Last edited by Corona688; 03-29-2011 at 04:25 PM..
 

4 More Discussions You Might Find Interesting

1. SCO

BASH-like feature. is possible ?

Greetings... i was wondering if there is any shell configuration or third party application that enables the command history by pressing keyboard up arrow, like GNU/BASH does or are there an SCO compatible bash versio to download? where ? just wondering (sory my stinky english) (2 Replies)
Discussion started by: nEuRoMaNcEr
2 Replies

2. Shell Programming and Scripting

Creating a command history feature in a simple UNIX shell using C

I'm trying to write a history feature to a very simple UNIX shell that will list the last 10 commands used when control-c is pressed. A user can then run a previous command by typing r x, where x is the first letter of the command. I'm having quite a bit of trouble figuring out what I need to do, I... (2 Replies)
Discussion started by: -=Cn=-
2 Replies

3. UNIX for Dummies Questions & Answers

brainstorming automated response

I am managing a database of files for which there is a drop-box and multiple users. what i would like to do is set a criteria for files coming into the drop-box based on file structure. (they must be like this W*/image/W*-1234/0-999.tif) If the files do not match the criteria i want them to be... (1 Reply)
Discussion started by: Movomito
1 Replies

4. UNIX for Beginners Questions & Answers

Can we create any check-point feature in shell ?

I have a script as below and say its failed @ function fs_ck {} then it should exit and next time i execute it it should start from fs_ck {} only Please advise #!/bin/bash logging {} fs_ck {} bkp {} dply {} ## main function### echo Sstarting script echo '####' logging fs_ck... (3 Replies)
Discussion started by: abhaydas
3 Replies
All times are GMT -4. The time now is 07:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy