Fossil SCM
On unix with the "fossil ui" command, try to open the webbrowser with "xdg-open" and "gnome-open" prior to resorting to "firefox". Ticket [8bc2549cedcd599556bbaf131f03b96588701f20]
Commit
3a7e3e427d19e9b1ab1c4d8017d53c5a58122091
Parent
ce5eb4070225c28…
1 file changed
+36
-1
+36
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -702,10 +702,34 @@ | ||
| 702 | 702 | void cmd_test_http(void){ |
| 703 | 703 | login_set_capabilities("s"); |
| 704 | 704 | cmd_http(); |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | + | |
| 708 | +#if !defined(__DARWIN__) && !defined(__APPLE__) | |
| 709 | +/* | |
| 710 | +** Search for an executable on the PATH environment variable. | |
| 711 | +** Return true (1) if found and false (0) if not found. | |
| 712 | +*/ | |
| 713 | +static int binaryOnPath(const char *zBinary){ | |
| 714 | + const char *zPath = getenv("PATH"); | |
| 715 | + char *zFull; | |
| 716 | + int i; | |
| 717 | + int bExists; | |
| 718 | + while( zPath && zPath[0] ){ | |
| 719 | + while( zPath[0]==':' ) zPath++; | |
| 720 | + for(i=0; zPath[i] && zPath[i]!=':'; i++){} | |
| 721 | + zFull = mprintf("%.*s/%s", i, zPath, zBinary); | |
| 722 | + bExists = access(zFull, X_OK); | |
| 723 | + free(zFull); | |
| 724 | + if( bExists==0 ) return 1; | |
| 725 | + zPath += i; | |
| 726 | + } | |
| 727 | + return 0; | |
| 728 | +} | |
| 729 | +#endif | |
| 730 | + | |
| 707 | 731 | /* |
| 708 | 732 | ** COMMAND: server |
| 709 | 733 | ** COMMAND: ui |
| 710 | 734 | ** |
| 711 | 735 | ** Usage: %fossil server ?-P|--port TCPPORT? ?REPOSITORY? |
| @@ -745,11 +769,22 @@ | ||
| 745 | 769 | } |
| 746 | 770 | #ifndef __MINGW32__ |
| 747 | 771 | /* Unix implementation */ |
| 748 | 772 | if( g.argv[1][0]=='u' ){ |
| 749 | 773 | #if !defined(__DARWIN__) && !defined(__APPLE__) |
| 750 | - zBrowser = db_get("web-browser", "firefox"); | |
| 774 | + zBrowser = db_get("web-browser", 0); | |
| 775 | + if( zBrowser==0 ){ | |
| 776 | + static char *azBrowserProg[] = { "xdg-open", "gnome-open", "firefox" }; | |
| 777 | + int i; | |
| 778 | + zBrowser = "echo"; | |
| 779 | + for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){ | |
| 780 | + if( binaryOnPath(azBrowserProg[i]) ){ | |
| 781 | + zBrowser = azBrowserProg[i]; | |
| 782 | + break; | |
| 783 | + } | |
| 784 | + } | |
| 785 | + } | |
| 751 | 786 | #else |
| 752 | 787 | zBrowser = db_get("web-browser", "open"); |
| 753 | 788 | #endif |
| 754 | 789 | zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 755 | 790 | } |
| 756 | 791 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -702,10 +702,34 @@ | |
| 702 | void cmd_test_http(void){ |
| 703 | login_set_capabilities("s"); |
| 704 | cmd_http(); |
| 705 | } |
| 706 | |
| 707 | /* |
| 708 | ** COMMAND: server |
| 709 | ** COMMAND: ui |
| 710 | ** |
| 711 | ** Usage: %fossil server ?-P|--port TCPPORT? ?REPOSITORY? |
| @@ -745,11 +769,22 @@ | |
| 745 | } |
| 746 | #ifndef __MINGW32__ |
| 747 | /* Unix implementation */ |
| 748 | if( g.argv[1][0]=='u' ){ |
| 749 | #if !defined(__DARWIN__) && !defined(__APPLE__) |
| 750 | zBrowser = db_get("web-browser", "firefox"); |
| 751 | #else |
| 752 | zBrowser = db_get("web-browser", "open"); |
| 753 | #endif |
| 754 | zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 755 | } |
| 756 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -702,10 +702,34 @@ | |
| 702 | void cmd_test_http(void){ |
| 703 | login_set_capabilities("s"); |
| 704 | cmd_http(); |
| 705 | } |
| 706 | |
| 707 | |
| 708 | #if !defined(__DARWIN__) && !defined(__APPLE__) |
| 709 | /* |
| 710 | ** Search for an executable on the PATH environment variable. |
| 711 | ** Return true (1) if found and false (0) if not found. |
| 712 | */ |
| 713 | static int binaryOnPath(const char *zBinary){ |
| 714 | const char *zPath = getenv("PATH"); |
| 715 | char *zFull; |
| 716 | int i; |
| 717 | int bExists; |
| 718 | while( zPath && zPath[0] ){ |
| 719 | while( zPath[0]==':' ) zPath++; |
| 720 | for(i=0; zPath[i] && zPath[i]!=':'; i++){} |
| 721 | zFull = mprintf("%.*s/%s", i, zPath, zBinary); |
| 722 | bExists = access(zFull, X_OK); |
| 723 | free(zFull); |
| 724 | if( bExists==0 ) return 1; |
| 725 | zPath += i; |
| 726 | } |
| 727 | return 0; |
| 728 | } |
| 729 | #endif |
| 730 | |
| 731 | /* |
| 732 | ** COMMAND: server |
| 733 | ** COMMAND: ui |
| 734 | ** |
| 735 | ** Usage: %fossil server ?-P|--port TCPPORT? ?REPOSITORY? |
| @@ -745,11 +769,22 @@ | |
| 769 | } |
| 770 | #ifndef __MINGW32__ |
| 771 | /* Unix implementation */ |
| 772 | if( g.argv[1][0]=='u' ){ |
| 773 | #if !defined(__DARWIN__) && !defined(__APPLE__) |
| 774 | zBrowser = db_get("web-browser", 0); |
| 775 | if( zBrowser==0 ){ |
| 776 | static char *azBrowserProg[] = { "xdg-open", "gnome-open", "firefox" }; |
| 777 | int i; |
| 778 | zBrowser = "echo"; |
| 779 | for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){ |
| 780 | if( binaryOnPath(azBrowserProg[i]) ){ |
| 781 | zBrowser = azBrowserProg[i]; |
| 782 | break; |
| 783 | } |
| 784 | } |
| 785 | } |
| 786 | #else |
| 787 | zBrowser = db_get("web-browser", "open"); |
| 788 | #endif |
| 789 | zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser); |
| 790 | } |
| 791 |