On Wed, 2007-07-18 at 09:41 +0200, Tito wrote:
> On Wednesday 18 July 2007 01:10:40 Denis Vlasenko wrote:
>
> > Applied to svn with minor changes. For example, we were comparing argv[0]
> > with "view", but argv[0] can be "/bin/view"! Right thing is
> >
> > strncmp(appliet_name, "view", 4)
>
> Why not:
> if (*applet_name[3])
>
> Just an idea....
Good idea!
Actually, none of those works atm. include/applets needs to be updated.
ln -s busybox vi
./vi
[vi starts as expected]
ln -s busybox view
./view
view: applet not found
ln -sf vi view
./view
view: applet not found
Attatched patch fixes this. However...
I believe most people uses 'less' nowdays so we migh just want to
drop /bin/view completely.
People who absolutely want 'view' can create an alias:
alias view='vi -R'
btw... help message needs -c option.
> Ciao,
> Tito
>
> > BTW, any idea why strNcmp? Can it really be "viewsomething"? I'm no expert
> > on vi...
> > --
> > vda
Index: include/usage.h
===================================================================
--- include/usage.h (revision 19152)
+++ include/usage.h (working copy)
@@ -3740,6 +3740,11 @@
"\n\nOptions:\n" \
" -R Read-only - do not write to the file"
+#if ENABLE_FEATURE_VI_READONLY
+#define view_trivial_usage vi_trivial_usage
+#define view_full_usage vi_full_usage
+#endif
+
#define vlock_trivial_usage \
"[OPTIONS]"
#define vlock_full_usage \
Index: include/applets.h
===================================================================
--- include/applets.h (revision 19152)
+++ include/applets.h (working copy)
@@ -351,6 +351,10 @@
USE_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_FEATURE_VI_READONLY(
+ #define view_main vi_main
+ APPLET(view, _BB_DIR_BIN, _BB_SUID_NEVER)
+)
USE_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS))
USE_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_NEVER))
Index: editors/vi.c
===================================================================
--- editors/vi.c (revision 19152)
+++ editors/vi.c (working copy)
@@ -330,7 +330,9 @@
last_status_cksum = 0;
text = NULL;
- if (ENABLE_FEATURE_VI_READONLY && strncmp(applet_name, "view", 4) == 0) {
+ /* we have 2 alternatives for applet_name: vi and view
+ * *applet_name[3] means that its not "vi" so it has to be "view" */
+ if (ENABLE_FEATURE_VI_READONLY && applet_name[3]) {
SET_READONLY_MODE(readonly_mode);
}
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox