LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-24-2012, 02:12 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 478

Rep: Reputation: 47
executed konsole from script does not "inherit" functions


Example

Code:
#!/bin/bash

export VAR1=dummyvar1
export VAR2=dummyvar2

VAR_FUNC ()
{
export VAR3=dummyvar3
}

konsole -T "test_function"
In the konsole that is started from the script.


Quote:
> env | grep VAR
VAR1=dummyvar1
VAR2=dummyvar2
> VAR_FUNC
bash: VAR_FUNC: command not found
If I source the script then the function is found within the terminal where I sourced the script but the konsole that is started from the script doesn't have the function defined.

Am I doing something wrong?
 
Old 01-25-2012, 10:13 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
No, functions aren't something made available to subprocesses by default.

But bash does allow you to manually export them with the declare or export builtins.

Code:
export -f VAR_FUNC
sourcing is probably a better option overall though.
 
Old 01-25-2012, 01:03 PM   #3
sharky
Member
 
Registered: Oct 2002
Posts: 478

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by David the H. View Post
No, functions aren't something made available to subprocesses by default.

But bash does allow you to manually export them with the declare or export builtins.

Code:
export -f VAR_FUNC
sourcing is probably a better option overall though.
That does it. thx.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
"ps" command not executed in script when using crontab Annielover Linux - General 6 06-06-2011 03:22 PM
The "Log out" and "Lock screen" actions cannot be executed through keyboard shortcuts Snood Linux - Desktop 0 04-22-2009 10:30 AM
"GRUB _" when booting, nothing but "ctrl+alt+del" functions rabidpencil Linux - Newbie 15 08-08-2006 11:20 AM
C/C++ functions similar to BASH's "cp", "mv", "mkdir", etc? kornerr Programming 10 04-23-2006 10:48 AM
"ifcfg-ethx" and "network-functions" files peok Linux - Networking 12 08-13-2003 07:06 PM


All times are GMT -5. The time now is 12:50 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration