LinuxQuestions.org
Help answer threads with 0 replies.
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 11-24-2021, 12:05 AM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 817

Rep: Reputation: 58
Can a bash be used to write a command line utility/program?


Is it possible to create a text editor like nano using only bash?
 
Old 11-24-2021, 12:59 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,224
Blog Entries: 1

Rep: Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585
Sure.

Edit: libtool is an example for a complex utility that is a shell-script.

Last edited by NevemTeve; 11-24-2021 at 02:03 AM.
 
1 members found this post helpful.
Old 11-24-2021, 01:07 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 17,204

Rep: Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824
Sure. Yes. You can see a calculator here written in pure bash (just to have an idea).

And it looks like it is a much better example: https://github.com/comfies/bed

Last edited by pan64; 11-24-2021 at 01:10 AM.
 
1 members found this post helpful.
Old 11-24-2021, 01:14 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,037

Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
You can see a calculator here written in pure bash
Not even in Bash. In POSIX shell (which is a subset of Bash).
 
1 members found this post helpful.
Old 11-24-2021, 09:57 AM   #5
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 817

Original Poster
Rep: Reputation: 58
Quote:
Originally Posted by pan64 View Post
And it looks like it is a much better example: https://github.com/comfies/bed
Wow! So cool how powerful just bash alone is.

While I've got ya here, I am curious, is there a way to make the text selectable with a mouse in a bash text editor like that? I know that there is different terminal types and some have advantages over the other. I am curious if that kind of functionality is terminal dependent.

Also, what about images? Is there a way to display images in a terminal in a bash program?
 
Old 11-24-2021, 10:10 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 17,204

Rep: Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824Reputation: 5824
probably you can do the search.
 
Old 11-24-2021, 11:03 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,224
Blog Entries: 1

Rep: Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585
Without `ncurses` (or similar library) you would have to handle the escape-sequences sent by the terminal(emulator) manually. Mouse clicks are also reported as such sequences.
You can start here: https://man7.org/linux/man-pages/man...e_codes.4.html

Regarding images: google for ASCII-art

Last edited by NevemTeve; 11-24-2021 at 11:10 AM.
 
1 members found this post helpful.
  


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
LXer: What is chattr command in Linux command-line utility. LXer Syndicated Linux News 0 01-03-2021 10:12 PM
[SOLVED] base64 encoding in program vs piping to base64 command-line utility 0x53h Linux - General 3 08-05-2016 11:39 AM
escape string in bash script so it can be used in command line BuckRogers01 Linux - Software 15 08-12-2010 10:38 AM
grab the line below a blank line and the line above the next blank line awk or perl? Pantomime Linux - General 7 06-26-2008 09:13 AM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 01:24 AM

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

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