LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-02-2006, 06:48 PM   #1
essdeeay
Member
 
Registered: Aug 2004
Location: United Kingdom
Distribution: Debian
Posts: 88

Rep: Reputation: 15
Question Order of functions in a bash script


I'm writing a script which is becoming a little on the lengthy side for easy management (>100 lines). Instead of having half-a dozen nested IFs, I've chosen to use a sequence of single-level IFs and a few control variables that are set during the IFs.

However, I don't want to have to trawl through all these IFs to be able to edit the main body of the program. I can use a function, but this still has to be defined before it's used.

Is there any way I can push this stuff down to the bottom of the script somewhere and leave me with all the nice stuff at the top to edit?

Thanks,
Steve
 
Old 05-02-2006, 10:52 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
No, but you can put the fns in another sh file and include it at the top of your main script in one line via

. fns.sh
or
source fns.sh

Note that the first version (ie dot space filename) also works in ksh and prob other shells as well.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
startup script order berrance Linux - Software 4 10-13-2005 02:49 PM
shell script functions iNET_boss Linux - General 1 08-10-2005 04:41 PM
logrotate log files - keeping in order when using grep or cat and bash dmellem Linux - Software 6 02-11-2005 01:05 PM
[bash-scripting]functions + arguments hylke Programming 14 10-05-2004 01:48 AM
dvorak layout = can't use bash functions with xterm elconde Linux - General 2 03-14-2004 05:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration