LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-26-2013, 02:47 AM   #1
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 116

Rep: Reputation: 6
Question vim and different links


Hello,

I have installed vim to the /usr/local:
Code:
ls -la | grep -i vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 eview -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 evim -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 ex -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 gview -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 gvim -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 gvimdiff -> vim
-rwxr-xr-x   1 bin      bin          143 Sep 26  2010 gvimtutor
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 rgview -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 rgvim -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 rview -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 rvim -> vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 view -> vim
-rwxr-xr-x   1 bin      bin      1727992 Sep 26  2010 vim
lrwxrwxrwx   1 root     root           3 Dec 18 20:40 vimdiff -> vim
-rwxr-xr-x   1 bin      bin         2084 Sep 26  2010 vimtutor
when I type gvim, it launched GUI-based vim. But gvim is only a link to a vim itself. How vim determined that it was called via symbolic link and it's required to launch GUI-based vim?
 
Old 12-26-2013, 03:00 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Quote:
Originally Posted by sluge View Post
when I type gvim, it launched GUI-based vim. But gvim is only a link to a vim itself. How vim determined that it was called via symbolic link and it's required to launch GUI-based vim?
When the program is started it looks which command was actually used to start it. I'm not a C programmer but here's how you can simulate it using bash:
Code:
$ ls -l
lrwxrwxrwx 1 druuna druuna   2 dec 26 09:56 off -> on
-rwxr-x--- 1 druuna druuna 121 dec 26 09:56 on

$ ./on
turn it on
$ ./off
turn it off
Content of the on script:
Code:
#!/bin/bash

calledAs=$(basename $0)

if [[ "$calledAs" == "on" ]]
then
  echo "turn it on"
else
  echo "turn it off"
fi
 
Old 12-26-2013, 12:20 PM   #3
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 326

Rep: Reputation: 73
In C you can get it with argv[0]
Code:
int main (int argc, char **argv)
 
  


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
vim tutorial in 5 minute, learn vi/vim is to know what the letters stand for cheats anish2good Linux - Newbie 1 07-16-2013 12:23 PM
web page/links links/links vendtagain Linux - Newbie 2 09-19-2009 08:13 PM
Switching from vim to vim -g from inside vim iDragoon Linux - Software 4 05-15-2009 11:46 AM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 04:26 PM
links (hard links and soft links..) sachitha Programming 1 08-10-2005 12:10 PM


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