US stock indexes dipped lower on Thursday, but only after a circuitous ride that saw them flip multiple times between small gains and losses.
It is the latest meandering course for a market that has been pushed in many directions the last few weeks.
Food companies struggled after the makers of Spam and Folgers coffee reported weaker-than-expected results, and grocers fell after Amazon said it plans to cut prices for avocados, eggs and other products when it takes control of Whole Foods next week.
Retailers, meanwhile, were big winners after a wide variety said they earned fatter profits last quarter than Wall Street forecast.
The Standard & Poor's 500 index fell 5.07 points, or 0.2%, to 2,438.97.
Through the day, it flipped between gains of up to 0.3% and losses of up to 0.3%.
The Dow Jones industrial average fell 28.69 points, or 0.1%, to 21,783.40, the Nasdaq composite fell 7.08 points, or 0.1%, to 6,271.33 and the Russell 2000 index of small-cap stocks rose 4.14 points, or 0.3%, to 1,373.88.
The market has drifted up and down since the S&P 500 set a record high earlier this month.
Helping stocks has been strong growth in profits, and most S&P 500 companies have reported higher earnings for the spring quarter than analysts forecast, along with healthier revenue.
Hurting stocks have been worries about politics both in Washington and abroad.
Doubts are rising about how much help the Republican-led White House and Congress can provide for businesses.
Several crucial deadlines are coming up that could damage the economy, including a vote to avoid a default on the national debt, though most investors expect calamity to be averted.
This week has also featured lighter trading than usual, with few market-moving events on the calendar.
That may be exacerbating moves for the market. For all the noise, though, the S&P 500 is still within 1.7% of its record.
One event that could capture the market's attention is a symposium of central bankers in Jackson Hole, Wyoming.
Federal Reserve chair Janet Yellen and European Central Bank president Mario Draghi are both expected to speak at the meeting on Friday.
Few analysts expect to hear major surprises.
"I can't imagine anything significant outside of what we already know, which is that over time global rates will move up," said Tom Stringfellow, chief investment officer of Frost Investment Advisers.
"Maybe we'll get some commentary on how they'll manage it to keep debt markets calm."
With rates on the way up, Stringfellow said he expects the market to become increasingly split between winners and losers.
That would be a change from prior years, when markets often rose and fell in unison.
On Thursday, the New York Stock Exchange was nearly evenly split between stocks that rose and fell.
On the losing side was J.M. Smucker, which had the biggest loss in the S&P 500 after reporting weaker profit for the latest quarter than Wall Street expected. It cited weaker-than-expected sales for Folgers coffee, and it also lowered the range for its forecast of full-year profit.
The stock dropped 11.34 dollars, or 9.5%, to 107.51 dollars.
Hormel Foods fell after it cut its forecast for full-year earnings due to higher costs for pork bellies and other ingredients.
Its stock lost 1.83 dollars, or 5.4%, to 32.09 dollars.
On the winning side were retailers, led by Signet Jewellers, which jumped 8.65 dollars, or 16.7%, to 60.54 dollars.
Strong sales of bracelets, rings and necklaces helped it report bigger revenue and profit for the latest quarter than analysts expected.
Signet also said it was acquiring R2Net, an online jewellery retailer, for 328 million dollars in cash.
Dollar Tree, whose stores sell $1 towels and $1 Champagne flutes, surged after it reported stronger earnings than Wall Street forecast.
Customers bought more at each store visit than they did a year ago, and the company raised its forecast for profit this year.
Dollar Tree's stock rose 4.18 dollars, or 5.6%, to 78.50 dollars.
In overseas markets, France's CAC 40 was close to flat, the FTSE 100 in London climbed 0.3% and Germany's Dax index gained 0.1%.
Japan's Nikkei 225 index fell 0.4%, the Hang Seng in Hong Kong rose 0.4% and South Korea's Kospi index gained 0.4%.
The yield on the 10-year Treasury rose to 2.20% from 2.17% late on Wednesday.
The two-year yield held steady at 1.31%, and the 30-year yield climbed to 2.77% from 2.75%.
The dollar rose to 109.51 to Japanese yen from 109.01 yen late on Wednesday.
The euro fell to 1.1806 from 1.1821 dollars, and the British pound slipped to 1.2802 from 1.2804 dollars.
Shares of refiners rose along with the price of gasoline as Hurricane Harvey approached the Texas coast of the Gulf of Mexico, which is home to many refineries.
Valero Energy rose 1.73 dollars, or 2.6%, to 67.44 dollars, and Marathon Petroleum gained 96 cents, or 1.9%, to 51.13 dollars.
Wholesale petrol futures rose five cents, or 2.8%, to 1.66 dollars per gallon.
Benchmark US crude fell 98 cents, or 2%, to settle at 47.43 dollars per barrel.
Brent crude, the international standard, fell 53 cents, or 1%, to settle at 52.04 dollars a barrel.
Natural gas rose two cents to settle at 2.95 dollars per 1,000 cubic feet, heating oil was close to flat at 1.62 dollars per gallon.
Gold lost 2.70 to settle at 1,292.00 dollars per ounce, silver fell eight cents to 16.96 dollars per ounce and copper added five cents to 3.03 dollars per pound.