|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
vi "set backup" option
I'm wondering if this is the expected behaviour or if it's a bug.
With the following in ~/.nexrc Code:
set backup=N"/home/$user/.vi/backup/%~" Code:
vi dev/x.py Code:
Error: /home/$user/.vi/backup/dev/x.py~: No such file or directory. On a somewhat related note, I must use set backup=N"/home/$user/.vi/backup/%~" because set backup=N"~/.vi/backup/%~" also errors with: Code:
Error: "~/.vi/backup/%~": No such file or directory. |
|
|||
On FreeBSD 12 with:
Code:
set backup=N"/home/$USER/.vi/backup/%.bak~ $ cd Iowa_caucus ; vi dhondt.sh Code:
[adriaan@ProliantX /usr/home/adriaan/.vi/backup]$ ls -ltr total 20 -rw------- 1 adriaan adriaan 12 Feb 24 00:53 aap.bak1 -rw------- 1 adriaan adriaan 29 Feb 24 00:55 aap.bak2 -rw------- 1 adriaan adriaan 110 Feb 24 01:06 aap.bak~1 -rw------- 1 adriaan adriaan 1298 Feb 24 01:09 dhondt.sh.bak~1 -rw------- 1 adriaan adriaan 1326 Feb 24 01:10 dhondt.sh.bak~2 $ vi Iowa_caucus/dhondt.sh I get the following error:Code:
+=+=+=+=+=+=+=+ Error: /home/adriaan/.vi/backup/Iowa_caucus/dhondt.sh.bak~: No such file or directory. Press any key to continue [: to enter more ex commands]:
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
||||
What happens if you create a sub-directory of the backup directory with the same name as the sub-directory the file is in? In toprank's example this would be
/home/$user/.vi/backup/dev and in J65nko's example it would be /home/$USER/.vi/backup/Iowa_caucus I am guessing that vi is unwilling to create this itself. |
|
|||
If I create the subdirectories in ~/.vi/backup, it works; however, I don't feel like recreating the system's directory tree in ~/.vi/backup. And creating the subdirectory prior to editing a file negates the utility of the set backup feature as I may as well just mkdir -p .vi/backup/file/path; cp file/path/file.name ~/.vi/backup/file/path/; vi file/path/file.name myself.
If the developers are aware that this is how it functions or purposely made it this way, that's cool; I wasn't sure if that's the case or if it's a bug, and would file a bug report if the latter. |
|
|||
Vi substitutes "%" with whatever was passed on the commandline. So if you edit ../somefile, it'll put the backup in ~/.vi/
Not ideal... |
|
||||
I don't know why vi does it the way it does ... but FWIW here's my thinking about it.
If all backup files were put in the same directory (say, the top level ~/.vi/backup directory) then there could be collisions between the backups of files with the same name that originate in different directories, e.g., dir1/file and dir2/file In an attempt to mitigate this problem, vi could create the necessary sub-directories. However, a little thought shows this will not solve all possible collision problems. So maybe they want the user to create these directories so they can be aware of and manage the potential issues? That's all just a guessing on my part, and I haven't thought it through further than that. Quite possible there's another or better reason for how it works. |
|
|||
Also, if it didn't use the full path, in the typical use case where you want the backup saved in the same directory as the original file, editing ../somefile or docs/otherfile has to conider the path part or the backup will end up in the user's current directory, and not in the directory with the file.
It should probaby do something different if you specify an absolute path as the backup directory. |
|
|||
Quote:
Code:
$ vi Iowa_caucus/dhondt.sh Iowa_caucus/dhondt.sh: 82 lines, 1299 characters. $ ls -ltrR .vi total 4 drwxr-xr-x 3 adriaan adriaan 512 Feb 24 19:19 backup .vi/backup: total 24 -rw------- 1 adriaan adriaan 12 Feb 24 00:53 aap.bak1 -rw------- 1 adriaan adriaan 29 Feb 24 00:55 aap.bak2 -rw------- 1 adriaan adriaan 110 Feb 24 01:06 aap.bak~1 -rw------- 1 adriaan adriaan 1298 Feb 24 01:09 dhondt.sh.bak~1 -rw------- 1 adriaan adriaan 1326 Feb 24 01:10 dhondt.sh.bak~2 drwxr-xr-x 2 adriaan adriaan 512 Feb 24 19:20 Iowa_caucus .vi/backup/Iowa_caucus: total 4 -rw------- 1 adriaan adriaan 1331 Feb 24 19:20 dhondt.sh.bak1
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
I made a small shell script that will do backups for vi.
If you use this script you must disable backups in .nexrc and/or .exrc. The script is here: https://gitlab.com/bsdun/vibak.sh |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
option "POWER" does not load | philo_neo71 | FreeBSD General | 0 | 22nd December 2017 06:59 PM |
Difference between"arp info overwritten" and " duplicate IP address " | varag | OpenBSD Security | 1 | 6th April 2015 02:57 PM |
How to replace "ectags" with "ctags"? | fender0107401 | OpenBSD Packages and Ports | 5 | 16th April 2013 10:01 AM |
Fixed "xinit" after _7 _8, "how" here in case anyones' "X" breaks... using "nvidia" | jb_daefo | Guides | 0 | 5th October 2009 09:31 PM |
"Thanks" and "Edit Tags". | diw | Feedback and Suggestions | 2 | 29th March 2009 12:06 AM |