LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-11-2018, 01:14 PM   #1
tankzeu
LQ Newbie
 
Registered: Sep 2018
Posts: 26

Rep: Reputation: Disabled
Shell script fixing recursion


I have this script which straight forward installs an application with version 10 and since now there are version 10 and 11 I have changed it to install the version based on the number you pass to $1.However after testing in the case of version 11 recursion happened with the same file and this logic I cannot move to another file to call,however I decided to call the same file with additional parameter $2 with value for example "XYZ" ,it works correctly ,however is it a bad practise?
 
Old 10-11-2018, 01:18 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by OP
version 11 recursion happened with the same file and this logic I cannot move to another file to call
no code to peak at so... if it works without damaging anything and without errors, is that a bad thing?

Last edited by BW-userx; 10-11-2018 at 01:19 PM.
 
Old 10-11-2018, 01:23 PM   #3
tankzeu
LQ Newbie
 
Registered: Sep 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
no code to peak at so... if it works without damaging anything and without errors, is that a bad thing?
it doesn't damage things,but for e.g in c++ where there is 1 parameter we cannot do this "trick" so I wondered if it is ok to use it or there is another way to get out of this situation minding the restriction I cannot call other .sh file and use the logic in the file
 
Old 10-11-2018, 01:47 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
explain this part in detail, so I can make sure I am on the same page as you.
"version 11 recursion happened with the same file"
what recursion, it tried to install twice? Because to me, installing an app via a script, with a version change, not much different should take place. all that is needed is an check and assignment of the version number then place it where needed within the script, and the install process should be the same.

post the script if you like, to get a better idea of your logic.
 
Old 10-11-2018, 01:47 PM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

You really should post an example of your code to clarify your question.

You're asking about the advisability of coding a certain way, you should show what you've coded.
 
Old 10-11-2018, 03:05 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
I have read the question several times and cannot make a best guess at what is being asked - but others should not have to guess what the question is!

Please review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!
 
Old 10-12-2018, 03:54 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Ditto to astrogeek ... the one thing we should have to do in order to help is make up our own ideas about what is being asked.
 
  


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
Fixing shell prompts GazL Slackware 9 08-07-2013 04:04 AM
[SOLVED] fixing ranges using shell script kswapnadevi Linux - Newbie 3 12-03-2010 01:24 PM
using recursion in bash script drkstr Linux - Software 4 07-09-2006 08:48 PM
tar: '--no-recursion' option doesn't prevent recursion Earl Parker II Slackware 12 08-17-2004 02:49 AM
Writing bash script with recursion.. ray5_83 Programming 4 08-04-2004 05:44 PM

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

All times are GMT -5. The time now is 08:52 AM.

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