LinuxQuestions.org
Review your favorite Linux distribution.
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 11-23-2021, 11:05 PM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Rep: Reputation: 61
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-23-2021, 11:59 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Sure.

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

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

Rep: Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344Reputation: 7344
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 12:10 AM.
 
1 members found this post helpful.
Old 11-24-2021, 12:14 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,678

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, 08:57 AM   #5
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 924

Original Poster
Rep: Reputation: 61
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, 09:10 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,033

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

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
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 10:10 AM.
 
1 members found this post helpful.
  


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

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

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