/ Check-in [92ded933]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Only print the "Loading resources from..." line when the output is a TTY. Ticket #168. (CVS 939)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92ded93376635f37e2f5a7a8f4077c85d5bce735
User & Date: drh 2003-04-26 02:50:11
Context
2003-04-26
03:03
Fix the shell tool to do a better job of ignoring whitespace. Ticket #234. (CVS 940) check-in: 639957e9 user: drh tags: trunk
02:50
Only print the "Loading resources from..." line when the output is a TTY. Ticket #168. (CVS 939) check-in: 92ded933 user: drh tags: trunk
02:40
Do not use the return value of fcntl() to find the reason that it failed. Use errno instead. Tickets #240 and #270. (CVS 938) check-in: acf9e980 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.71 2003/04/24 01:45:04 drh Exp $
           15  +** $Id: shell.c,v 1.72 2003/04/26 02:50:11 drh Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include "sqlite.h"
    21     21   #include <ctype.h>
    22     22   
................................................................................
    42     42   #else
    43     43   # define readline(p) getline(p,stdin)
    44     44   # define add_history(X)
    45     45   # define read_history(X)
    46     46   # define write_history(X)
    47     47   # define stifle_history(X)
    48     48   #endif
           49  +
           50  +/* Make sure isatty() has a prototype.
           51  +*/
           52  +extern int isatty();
    49     53   
    50     54   /*
    51     55   ** The following is the open SQLite database.  We make a pointer
    52     56   ** to this database a static variable so that it can be accessed
    53     57   ** by the SIGINT handler to interrupt database processing.
    54     58   */
    55     59   static sqlite *db = 0;
................................................................................
  1042   1046         fprintf(stderr,"%s: out of memory!\n", Argv0);
  1043   1047         exit(1);
  1044   1048       }
  1045   1049       sprintf(sqliterc,"%s/.sqliterc",home_dir);
  1046   1050       free(home_dir);
  1047   1051     }
  1048   1052     in = fopen(sqliterc,"r");
  1049         -  if(in) {
         1053  +  if(in && isatty(fileno(stdout))) {
  1050   1054       printf("Loading resources from %s\n",sqliterc);
  1051   1055       process_input(p,in);
  1052   1056       fclose(in);
  1053   1057     }
  1054   1058     return;
  1055   1059   }
  1056   1060   
................................................................................
  1178   1182         rc = sqlite_exec(db, argv[2], callback, &data, &zErrMsg);
  1179   1183         if( rc!=0 && zErrMsg!=0 ){
  1180   1184           fprintf(stderr,"SQL error: %s\n", zErrMsg);
  1181   1185           exit(1);
  1182   1186         }
  1183   1187       }
  1184   1188     }else{
  1185         -    extern int isatty();
  1186   1189       if( isatty(fileno(stdout)) && isatty(fileno(stdin)) ){
  1187   1190         char *zHome;
  1188   1191         char *zHistory = 0;
  1189   1192         printf(
  1190   1193           "SQLite version %s\n"
  1191   1194           "Enter \".help\" for instructions\n",
  1192   1195           sqlite_version