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 12-01-2023, 12:24 AM   #16
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36

Thanks! I'm not depending on it anymore in my current version, but I will definately add that flag to the top of my file, for now future issues. I'll try an remember to put that also in any script which calls this.
 
Old 12-01-2023, 12:34 AM   #17
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
So when I used this, unless I called it with set -f; specifically, when changing it to '?' again, it didn't work still. It used to just work before. So I'm sticking with my new character, '-'. However, I added that -f flag for a future time, and explained what the comment does. I do NOT want to require major tweaks or specific knowlege of that feature for running the script, as most users besides me, of them will NOT know about that feature yet. This is designed for people on my network, most of which may not know how to turn a computer on until I teach them. At least that's true of my guests so far. I will work on the cross platform stuff a bit later. Right now the goal is to get my scripts to work on Linux Mint 21.2.
 
Old 12-01-2023, 12:35 AM   #18
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Here's my code for the help system:

shelp.sh
Code:
#! /bin/bash -f

# If this script is called by another script, you must also use -f flag, which causes the shell not to glob.

if [ $# -lt 1 ]; then
  echo "Usage: shelp.sh {command} {topic}"
  echo
  echo "       help                             - Gets bash help."
  echo "       man                              - Gets a man page"
  echo "       xman                             - Browses the man pages graphically"
  echo "       info                             - Gets an info page"
  echo "       tldr                             - Gets a tldr page. Needs sudo permissions!"
  echo "       - {section or . for all}         - List the section help topics"
  echo "       - {section} {topic}              - Gets standard script help"
  echo
else
 if [ $1 == "man" ]; then
  shift
  man $@
 elif [ $1 == "xman" ]; then
  shift
  xman $@ &
 elif [ $1 == "info" ]; then
  shift
  info $@
 elif [ $1 == "help" ]; then
  shift
  help $@
 elif [ $1 == "tldr" ]; then
  shift
  sudo tldr $@
 elif [ $1 == "-" ]; then
  if [ $# -eq 2 ]; then
   if [ -d /etc/settings/shelp/$2 ]; then
    if [ $2 == ".." ]; then
     echo "What topic do you want?"
    else
     ls /etc/settings/shelp/$2
    fi
   else
    echo "What topic do you want?"
   fi
  elif [ $# -eq 3 ]; then
   if [ -f /etc/settings/shelp/$2/$3 ]; then
    less /etc/settings/shelp/$2/$3
   fi
  else
   echo "What topic do you want?"
  fi
 else
  echo "Usage: shelp.sh {command} {topic}"
  echo
  echo "       help                             - Gets bash help."
  echo "       man                              - Gets a man page"
  echo "       xman                             - Browses the man pages graphically"
  echo "       info                             - Gets an info page"
  echo "       tldr                             - Gets a tldr page. Needs sudo permissions!"
  echo "       - {section or . for all}         - List the section help topics"
  echo "       - {section} {topic}              - Gets standard script help"
  echo
 fi
fi
 
Old 12-01-2023, 01:38 AM   #19
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
...And I think I have enough features implemented for it to be a complete version! As soon as I can, I will upload it to github, so that everyone can now benefit from my work. However, before I do that, I must build a bit on top of it, and implement just a little bit more. I have to make sure it works.

I don't know why, besides needing Linux to have the features I need, that I didn't just try to fully switch to Linux earlier. Because, did you know (since I already knew the basic bash language), that in order to set up a new Linux Mint machine, all I have to do, is run some scripts in the right order and do as the onscreen prompts I've designed, asks me to do. They are currently installed the Windows way, but it works for now. However, those scripts run in a certain order, and because of package managers, then my system is completely ready to go. It's great! I used to have to spend days doing the setup of things on Windows! Not to mention, until I fully document every step of the way, I can't completely set up any windows system! I will still support it on my network, but not recommend it maybe. Pretty cool now!
 
  


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
[SOLVED] Standard Scripts for Linux: Bash Script to List all Files Inside a Directory, Line by Line to Standard Output des_a Programming 13 01-12-2024 06:25 PM
LXer: Debugging Shell Scripts in Linux LXer Syndicated Linux News 0 02-23-2015 08:33 PM
[SOLVED] Effective debugging or improving ones debugging skills Ajit Gunge Programming 3 05-22-2009 09:29 AM
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM

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

All times are GMT -5. The time now is 07:23 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