DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 3rd November 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default Csh - range expansion?

Hello,
There is very simple feature of the bash shell:
$ echo {0..9}
0 1 2 3 4 5 6 7 8 9
I want to use it in CSH. I've read the man page and searched Google, but didn't find anything on 'range expansion'. Maybe my english is so wrong that this operation is called something different?

How can I do this in csh?
Reply With Quote
  #2   (View Single Post)  
Old 3rd November 2008
richardpl richardpl is offline
Spam Deminer
 
Join Date: May 2008
Location: Croatia
Posts: 284
Default

Side note: you should not make/attempt any programming in (t)csh.
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Use Bourne shell instead.
Reply With Quote
  #3   (View Single Post)  
Old 3rd November 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 445
Default

(I agree on the "don't program with csh" bit.)

I don't know of a csh feature to do this, but you might use the port misc/seq2.
__________________
Kill your t.v.
Reply With Quote
  #4   (View Single Post)  
Old 3rd November 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Default

Then why tcsh is the default shell in FreeBSD?
Reply With Quote
  #5   (View Single Post)  
Old 3rd November 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 445
Default

For interactive use! (Not for programming.)
__________________
Kill your t.v.
Reply With Quote
  #6   (View Single Post)  
Old 3rd November 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

There is no concept of a "default shell" beyond the programs you use to automate the process of adding new users, such as in adduser.conf and pw.conf to set defaults for adduser/pw. Looking at the adduser script, I would think pardoning setting a default shell in their configuration files, that adduser defaults to /bin/sh and I've no time to hunt down what my beloved pw defaults to if anything.

In fact, /sbin/init defaults to /bin/sh for single user mode.



Once upon a time, the C Shell was considered more usable for interactive work then the original Bourne Shell. Things like job control, command history, aliases - which eventually became ubiquitous through csh. The by modern standards, the tcsh is much better then the /bin/sh on FreeBSD, which is closer to the SVR4 Bourne Shell then what you would find on earlier research unix or bsd unix systems. The original C shell was also a BSD thing, so go figure...
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.

Last edited by TerryP; 3rd November 2008 at 08:14 PM.
Reply With Quote
  #7   (View Single Post)  
Old 3rd November 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Quote:
I don't know of a csh feature to do this, but you might use the port misc/seq2.
seq is the GNU/Linux tool, FreeBSD, OpenBSD (And NetBSD?) come with jot(1), i.e.:
Code:
% jot -s ' ' - 0 9
0 1 2 3 4 5 6 7 8 9
Arguably, the built-in bash syntax is easier to use and understand ... But the end result is the same nonetheless.

tcsh is (in my opinion) an excellent interactive shell, it supports most features bash does, and generally just works well.
However, (t)csh is not a very good scripting language, as stated above, this is a entirely different task, FreeBSD has /bin/sh for that.
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #8   (View Single Post)  
Old 3rd November 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 445
Default

Quote:
Originally Posted by Carpetsmoker
... FreeBSD, OpenBSD (And NetBSD?) come with jot(1), i.e.:
Code:
% jot -s ' ' - 0 9
0 1 2 3 4 5 6 7 8 9
Even better - something already in the base system.

So to OP I would recommend jot.
__________________
Kill your t.v.
Reply With Quote
  #9   (View Single Post)  
Old 4th November 2008
mdh's Avatar
mdh mdh is offline
Real Name: Matt D. Harris
FreeBSD 2.2.6 User
 
Join Date: Oct 2008
Location: West Virginia
Posts: 139
Default

To oversimplify things, let me state in a vastly oversimplified manner...

tcsh is an interactive-friendly version of csh.

bash is an interactive-friendly version sh.

Honestly though, any C programmer ends up having to write sh code at some point (Makefiles, etc) so the simple fact is that csh isn't terrible useful to us either, since we've gotta know sh regardless. Anything more than executing commands and such though, a C programmer should be able to pick up basic Perl very easily. It's extremely powerful despite being as simple as sh if you want it to be.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:07 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick